magnet time
This commit is contained in:
parent
51411883f4
commit
c57aeacc98
1 changed files with 22 additions and 0 deletions
22
src/main.js
22
src/main.js
|
|
@ -503,6 +503,8 @@ function attack(name, ...args) {
|
||||||
} else {
|
} else {
|
||||||
obj.vy = player.y > obj.y ? -1 : 1
|
obj.vy = player.y > obj.y ? -1 : 1
|
||||||
}
|
}
|
||||||
|
obj.vx *=2
|
||||||
|
obj.vy *=2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const anim = createAttackAnim(player, (50 + extraRadius + extraRadius) * 1.25 )
|
const anim = createAttackAnim(player, (50 + extraRadius + extraRadius) * 1.25 )
|
||||||
|
|
@ -620,6 +622,26 @@ function play(delta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chargeLen > 0) {
|
||||||
|
const extraRadius = 50
|
||||||
|
const playerRect = {
|
||||||
|
x: player.x - extraRadius,
|
||||||
|
y: player.y - extraRadius,
|
||||||
|
width: player.width + extraRadius + extraRadius,
|
||||||
|
height: player.height + extraRadius + extraRadius,
|
||||||
|
}
|
||||||
|
for (const obj of objects) {
|
||||||
|
if (hitTestRectangle(playerRect, obj)) {
|
||||||
|
const dir = player.x > obj.x ? 1 : -1
|
||||||
|
obj.vrot = .1 * dir
|
||||||
|
obj.ticks += 1
|
||||||
|
|
||||||
|
obj.vx = player.x > obj.x ? 1 : -1
|
||||||
|
obj.vy = player.y > obj.y ? 1 : -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const c of objects) {
|
for (const c of objects) {
|
||||||
if (c.type === 'cow') {
|
if (c.type === 'cow') {
|
||||||
if (c.vrot > 0 && c.ticks > 0) {
|
if (c.vrot > 0 && c.ticks > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue