mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +00:00
game: simplify detection effect
This commit is contained in:
parent
430aef1ffd
commit
beac3b50c0
1 changed files with 20 additions and 18 deletions
34
game.js
34
game.js
|
|
@ -156,7 +156,7 @@ function spawn() {
|
||||||
x: enemy.x[0],
|
x: enemy.x[0],
|
||||||
y: enemy.y[0],
|
y: enemy.y[0],
|
||||||
},
|
},
|
||||||
frames: [...Array(5).fill(4)],
|
frames: Array(5).fill(4),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -237,22 +237,25 @@ function drawFX() {
|
||||||
rect(to.x - frames.length, 0, frames.length * 2, SCREEN_W, color)
|
rect(to.x - frames.length, 0, frames.length * 2, SCREEN_W, color)
|
||||||
},
|
},
|
||||||
detection: ({ to, frames }) => {
|
detection: ({ to, frames }) => {
|
||||||
|
// Array(5).fill(4)]
|
||||||
const color = frames.shift()
|
const color = frames.shift()
|
||||||
const r = arena.spriteHalfSize
|
const w = arena.spriteHalfSize
|
||||||
const d = frames.length + 2 * r
|
const d = frames.length + 2 * w
|
||||||
|
const corners = [
|
||||||
|
[+1, +1],
|
||||||
|
[+1, -1],
|
||||||
|
[-1, +1],
|
||||||
|
[-1, -1],
|
||||||
|
]
|
||||||
|
|
||||||
line(to.x - d, to.y - d, to.x - d + r, to.y - d + 0, color)
|
corners.forEach(([dx, dy]) => {
|
||||||
line(to.x - d, to.y - d, to.x - d + 0, to.y - d + r, color)
|
const x = to.x + dx * d
|
||||||
|
const y = to.y + dy * d
|
||||||
|
|
||||||
line(to.x + d, to.y - d, to.x + d - r, to.y - d + 0, color)
|
line(x, y, x - dx * w, y, color)
|
||||||
line(to.x + d, to.y - d, to.x + d - 0, to.y - d + r, color)
|
line(x, y, x, y - dy * w, color)
|
||||||
|
})
|
||||||
line(to.x + d, to.y + d, to.x + d - r, to.y + d + 0, color)
|
},
|
||||||
line(to.x + d, to.y + d, to.x + d - 0, to.y + d - r, color)
|
|
||||||
|
|
||||||
line(to.x - d, to.y + d, to.x - d + r, to.y + d + 0, color)
|
|
||||||
line(to.x - d, to.y + d, to.x - d + 0, to.y + d - r, color)
|
|
||||||
}
|
|
||||||
})[effect.type](effect),
|
})[effect.type](effect),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -272,7 +275,7 @@ function drawPlayer() {
|
||||||
// Utils
|
// Utils
|
||||||
|
|
||||||
function rnd(from, to) {
|
function rnd(from, to) {
|
||||||
return Math.floor(Math.random() * (to - from + 1)) + from;
|
return Math.floor(Math.random() * (to - from + 1)) + from
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
@ -336,4 +339,3 @@ const [BTN_U, BTN_D, BTN_L, BTN_R, BTN_A, BTN_B, BTN_X, BTN_Y] = [
|
||||||
// <PALETTE>
|
// <PALETTE>
|
||||||
// 000:000000002b36073642586e75657b8383949693a1a1ffffffb58900cb4b16dc322fd336826c71c4268bd22aa198859900
|
// 000:000000002b36073642586e75657b8383949693a1a1ffffffb58900cb4b16dc322fd336826c71c4268bd22aa198859900
|
||||||
// </PALETTE>
|
// </PALETTE>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue