mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +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],
|
x: enemies[0].x[0],
|
||||||
y: enemies[0].y[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()
|
enemies.shift()
|
||||||
trace(enemies.length)
|
trace(enemies.length)
|
||||||
|
|
@ -193,26 +193,25 @@ function drawArena() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawFX() {
|
function drawFX() {
|
||||||
const laser = (effect) => {
|
effects
|
||||||
const color = effect.frameColors.shift()
|
.map((effect) => ({
|
||||||
const from = arenaToScreen(effect.from)
|
...effect,
|
||||||
const to = arenaToScreen(effect.to)
|
from: arenaToScreen(effect.from),
|
||||||
|
to: arenaToScreen(effect.to),
|
||||||
line(from.x, from.y, to.x, to.y, color)
|
}))
|
||||||
|
.forEach((effect) =>
|
||||||
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) =>
|
|
||||||
({
|
({
|
||||||
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),
|
})[effect.type](effect),
|
||||||
)
|
)
|
||||||
|
|
||||||
effects = effects.filter(({ frameColors }) => frameColors.length > 0)
|
effects = effects.filter(({ frames }) => frames.length > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawEnemies() {
|
function drawEnemies() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue