mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +00:00
game: detection effect
This commit is contained in:
parent
7e1305ef42
commit
430aef1ffd
1 changed files with 36 additions and 3 deletions
39
game.js
39
game.js
|
|
@ -118,7 +118,7 @@ function handleMorse() {
|
||||||
if (btnp(BTN_B, 100, 100)) {
|
if (btnp(BTN_B, 100, 100)) {
|
||||||
if (enemies.length > 0) {
|
if (enemies.length > 0) {
|
||||||
effects.unshift({
|
effects.unshift({
|
||||||
type: 'verticalLine',
|
type: 'laser',
|
||||||
from: {
|
from: {
|
||||||
x: player.x,
|
x: player.x,
|
||||||
y: player.y,
|
y: player.y,
|
||||||
|
|
@ -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],
|
||||||
},
|
},
|
||||||
frames: [4, 5, 6, 7, 7, 6, 5, 4],
|
frames: [1, 2, 3, 4, 7, 7, 7, 6, 5, 4, 3, 2, 1],
|
||||||
})
|
})
|
||||||
enemies.shift()
|
enemies.shift()
|
||||||
trace(enemies.length)
|
trace(enemies.length)
|
||||||
|
|
@ -147,6 +147,18 @@ function spawn() {
|
||||||
dangerZone: 8,
|
dangerZone: 8,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
enemies.forEach((enemy) => {
|
||||||
|
effects.unshift({
|
||||||
|
type: 'detection',
|
||||||
|
from: {},
|
||||||
|
to: {
|
||||||
|
x: enemy.x[0],
|
||||||
|
y: enemy.y[0],
|
||||||
|
},
|
||||||
|
frames: [...Array(5).fill(4)],
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,9 +229,30 @@ function drawFX() {
|
||||||
verticalLine: ({ to, frames }) => {
|
verticalLine: ({ to, frames }) => {
|
||||||
// [4, 5, 6, 7, 7, 6, 5, 4]
|
// [4, 5, 6, 7, 7, 6, 5, 4]
|
||||||
const color = frames.shift()
|
const color = frames.shift()
|
||||||
|
|
||||||
rect(0, to.y - frames.length, SCREEN_W, frames.length * 2, color)
|
rect(0, to.y - frames.length, SCREEN_W, frames.length * 2, color)
|
||||||
},
|
},
|
||||||
|
horizontalLine: ({ to, frames }) => {
|
||||||
|
// [4, 5, 6, 7, 7, 6, 5, 4]
|
||||||
|
const color = frames.shift()
|
||||||
|
rect(to.x - frames.length, 0, frames.length * 2, SCREEN_W, color)
|
||||||
|
},
|
||||||
|
detection: ({ to, frames }) => {
|
||||||
|
const color = frames.shift()
|
||||||
|
const r = arena.spriteHalfSize
|
||||||
|
const d = frames.length + 2 * r
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue