mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +00:00
game: verticalLine effect
This commit is contained in:
parent
58dfa76836
commit
7e1305ef42
1 changed files with 20 additions and 4 deletions
24
game.js
24
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: 'laser',
|
type: 'verticalLine',
|
||||||
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: [1, 2, 3, 4, 7, 7, 7, 6, 5, 4, 3, 2, 1],
|
frames: [4, 5, 6, 7, 7, 6, 5, 4],
|
||||||
})
|
})
|
||||||
enemies.shift()
|
enemies.shift()
|
||||||
trace(enemies.length)
|
trace(enemies.length)
|
||||||
|
|
@ -202,7 +202,7 @@ function drawFX() {
|
||||||
.forEach((effect) =>
|
.forEach((effect) =>
|
||||||
({
|
({
|
||||||
laser: ({ from, to, frames }) => {
|
laser: ({ from, to, frames }) => {
|
||||||
// frames: [1, 2, 3, 4, 7, 7, 7, 6, 5, 4, 3, 2, 1],
|
// [1, 2, 3, 4, 7, 7, 7, 6, 5, 4, 3, 2, 1]
|
||||||
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)
|
||||||
circ(from.x, from.y, frames.length / 3, color)
|
circ(from.x, from.y, frames.length / 3, color)
|
||||||
|
|
@ -210,10 +210,16 @@ function drawFX() {
|
||||||
circb(to.x, to.y, frames.length, color + 3)
|
circb(to.x, to.y, frames.length, color + 3)
|
||||||
},
|
},
|
||||||
nuke: ({ to, frames }) => {
|
nuke: ({ to, frames }) => {
|
||||||
// frames: [6, 5, 4, 3, 2],
|
// [6, 5, 4, 3, 2]
|
||||||
const color = frames.shift()
|
const color = frames.shift()
|
||||||
circ(to.x, to.y, Math.pow(frames.length, 5), color)
|
circ(to.x, to.y, Math.pow(frames.length, 5), color)
|
||||||
},
|
},
|
||||||
|
verticalLine: ({ to, frames }) => {
|
||||||
|
// [4, 5, 6, 7, 7, 6, 5, 4]
|
||||||
|
const color = frames.shift()
|
||||||
|
|
||||||
|
rect(0, to.y - frames.length, SCREEN_W, frames.length * 2, color)
|
||||||
|
},
|
||||||
})[effect.type](effect),
|
})[effect.type](effect),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -230,8 +236,18 @@ function drawPlayer() {
|
||||||
drawSprite(player.sprite, player.x, player.y)
|
drawSprite(player.sprite, player.x, player.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Utils
|
||||||
|
|
||||||
|
function rnd(from, to) {
|
||||||
|
return Math.floor(Math.random() * (to - from + 1)) + from;
|
||||||
|
}
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
|
// Screen
|
||||||
|
const SCREEN_W = 240
|
||||||
|
const SCREEN_H = 136
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
const [BTN_U, BTN_D, BTN_L, BTN_R, BTN_A, BTN_B, BTN_X, BTN_Y] = [
|
const [BTN_U, BTN_D, BTN_L, BTN_R, BTN_A, BTN_B, BTN_X, BTN_Y] = [
|
||||||
...Array(8).keys(),
|
...Array(8).keys(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue