mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: inline effects
This commit is contained in:
parent
f18b4dff7a
commit
bb1a405c11
1 changed files with 19 additions and 20 deletions
33
game.js
33
game.js
|
|
@ -127,7 +127,7 @@ function handleMorse() {
|
|||
x: enemies[0].x[0],
|
||||
y: enemies[0].y[0],
|
||||
},
|
||||
frameColors: [1, 2, 3, 4, 7, 7, 7, 6, 5, 4, 3, 2, 1],
|
||||
frames: [1, 2, 3, 4, 7, 7, 7, 6, 5, 4, 3, 2, 1],
|
||||
})
|
||||
enemies.shift()
|
||||
trace(enemies.length)
|
||||
|
|
@ -193,26 +193,25 @@ function drawArena() {
|
|||
}
|
||||
|
||||
function drawFX() {
|
||||
const laser = (effect) => {
|
||||
const color = effect.frameColors.shift()
|
||||
const from = arenaToScreen(effect.from)
|
||||
const to = arenaToScreen(effect.to)
|
||||
|
||||
line(from.x, from.y, to.x, to.y, color)
|
||||
|
||||
circ(from.x, from.y, effect.frameColors.length / 2, color)
|
||||
|
||||
circ(to.x, to.y, effect.frameColors.length / 2, color)
|
||||
circb(to.x, to.y, effect.frameColors.length, color + 3)
|
||||
}
|
||||
|
||||
effects.forEach((effect) =>
|
||||
effects
|
||||
.map((effect) => ({
|
||||
...effect,
|
||||
from: arenaToScreen(effect.from),
|
||||
to: arenaToScreen(effect.to),
|
||||
}))
|
||||
.forEach((effect) =>
|
||||
({
|
||||
laser,
|
||||
laser: ({ from, to, frames }) => {
|
||||
const color = frames.shift()
|
||||
line(from.x, from.y, to.x, to.y, color)
|
||||
circ(from.x, from.y, frames.length / 2, color)
|
||||
circ(to.x, to.y, frames.length / 2, color)
|
||||
circb(to.x, to.y, frames.length, color + 3)
|
||||
},
|
||||
})[effect.type](effect),
|
||||
)
|
||||
|
||||
effects = effects.filter(({ frameColors }) => frameColors.length > 0)
|
||||
effects = effects.filter(({ frames }) => frames.length > 0)
|
||||
}
|
||||
|
||||
function drawEnemies() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue