mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: enemy types
This commit is contained in:
parent
0c8670a0cf
commit
f5c440feea
1 changed files with 30 additions and 9 deletions
37
game.js
37
game.js
|
|
@ -78,10 +78,16 @@ let player = {
|
|||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {'point' | 'fidget' | 'bounce' | 'zombie'} EnemyType
|
||||
*/
|
||||
/** @type EnemyType[] */
|
||||
const enemyTypes = ['point', 'fidget', 'bounce', 'zombie']
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* letter: string,
|
||||
* type: 'zombie',
|
||||
* type: EnemyType,
|
||||
* dangerZone: number,
|
||||
* positions: Point[],
|
||||
* }} Enemy
|
||||
|
|
@ -212,6 +218,18 @@ function spawn() {
|
|||
|
||||
arena.wave += 1
|
||||
|
||||
const enemyCount = 1 + Math.floor(arena.wave / 2)
|
||||
|
||||
const getType = (wave) => {
|
||||
if (wave < 2) return 'point'
|
||||
return enemyTypes[rnd(0, enemyTypes.length)]
|
||||
}
|
||||
|
||||
const getDangerZone = (type) => {
|
||||
if (type === 'zombie') return 6
|
||||
return 8
|
||||
}
|
||||
|
||||
const getSpawnPosition = () => {
|
||||
const minDistance = 50
|
||||
let x, y, distance
|
||||
|
|
@ -224,14 +242,17 @@ function spawn() {
|
|||
return { x, y }
|
||||
}
|
||||
|
||||
enemies = [
|
||||
{
|
||||
positions: [getSpawnPosition()],
|
||||
type: 'zombie',
|
||||
enemies = Array(enemyCount)
|
||||
.fill()
|
||||
.map(() => {
|
||||
const type = getType(arena.wave)
|
||||
return {
|
||||
type,
|
||||
letter: 'e',
|
||||
dangerZone: 8,
|
||||
},
|
||||
]
|
||||
positions: [getSpawnPosition()],
|
||||
dangerZone: getDangerZone(type),
|
||||
}
|
||||
})
|
||||
|
||||
enemies.forEach((enemy) => {
|
||||
effects.unshift({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue