mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +00:00
game: extract effectHandlers
This commit is contained in:
parent
bcc0e4b0b0
commit
8e6723efc3
1 changed files with 12 additions and 10 deletions
22
game.js
22
game.js
|
|
@ -357,15 +357,7 @@ function drawArena() {
|
||||||
map(0, 0, 30, 15)
|
map(0, 0, 30, 15)
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawFX() {
|
const effectHandlers = {
|
||||||
effects
|
|
||||||
.map((effect) => ({
|
|
||||||
...effect,
|
|
||||||
from: arenaToScreen(effect.from ?? {}),
|
|
||||||
to: arenaToScreen(effect.to ?? {}),
|
|
||||||
}))
|
|
||||||
.forEach((effect) =>
|
|
||||||
({
|
|
||||||
laser: ({ from, to, frames }) => {
|
laser: ({ from, to, frames }) => {
|
||||||
const color = frames.shift()
|
const color = frames.shift()
|
||||||
line(from.x, from.y, to.x, to.y, color)
|
line(from.x, from.y, to.x, to.y, color)
|
||||||
|
|
@ -404,7 +396,17 @@ function drawFX() {
|
||||||
line(x, y, x, y - dy * w, color)
|
line(x, y, x, y - dy * w, color)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})[effect.type](effect),
|
}
|
||||||
|
|
||||||
|
function drawFX() {
|
||||||
|
effects
|
||||||
|
.map((effect) => ({
|
||||||
|
...effect,
|
||||||
|
from: arenaToScreen(effect.from ?? {}),
|
||||||
|
to: arenaToScreen(effect.to ?? {}),
|
||||||
|
}))
|
||||||
|
.forEach((effect) =>
|
||||||
|
effectHandlers[effect.type](effect),
|
||||||
)
|
)
|
||||||
|
|
||||||
effects = effects.filter(({ frames }) => frames.length > 0)
|
effects = effects.filter(({ frames }) => frames.length > 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue