mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +00:00
game: simple js
This commit is contained in:
parent
901a746cd0
commit
28961352f5
1 changed files with 27 additions and 15 deletions
42
game.js
42
game.js
|
|
@ -287,23 +287,21 @@ function spawnEnemies() {
|
||||||
return { x, y }
|
return { x, y }
|
||||||
}
|
}
|
||||||
|
|
||||||
enemies = Array(enemyCount)
|
enemies = arr(enemyCount).map(() => {
|
||||||
.fill()
|
const type = getType(arena.wave)
|
||||||
.map(() => {
|
return {
|
||||||
const type = getType(arena.wave)
|
type,
|
||||||
return {
|
letter: 'e',
|
||||||
type,
|
positions: [getSpawnPosition(), getSpawnPosition()],
|
||||||
letter: 'e',
|
dangerZone: getDangerZone(type),
|
||||||
positions: [getSpawnPosition(), getSpawnPosition()],
|
}
|
||||||
dangerZone: getDangerZone(type),
|
})
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
enemies.forEach((enemy) => {
|
enemies.forEach((enemy) => {
|
||||||
effects.unshift({
|
effects.unshift({
|
||||||
type: 'detection',
|
type: 'detection',
|
||||||
to: enemy.positions[0],
|
to: enemy.positions[0],
|
||||||
frames: Array(10).fill(4),
|
frames: arr(10, 4),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -416,6 +414,15 @@ function drawFX() {
|
||||||
|
|
||||||
/* Utils */
|
/* Utils */
|
||||||
|
|
||||||
|
function arr(n, filler) {
|
||||||
|
const result = []
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
result.push(filler)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
function rnd(from, to) {
|
function rnd(from, to) {
|
||||||
return Math.floor(Math.random() * (to - from + 1)) + from
|
return Math.floor(Math.random() * (to - from + 1)) + from
|
||||||
}
|
}
|
||||||
|
|
@ -438,9 +445,14 @@ const SCREEN_W = 240
|
||||||
const SCREEN_H = 136
|
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 = 0;
|
||||||
...Array(8).keys(),
|
const BTN_D = 1;
|
||||||
]
|
const BTN_L = 2;
|
||||||
|
const BTN_R = 3;
|
||||||
|
const BTN_A = 4;
|
||||||
|
const BTN_B = 5;
|
||||||
|
const BTN_X = 6;
|
||||||
|
const BTN_Y = 7;
|
||||||
|
|
||||||
/* Types */
|
/* Types */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue