Add proper difficulty progression

This commit is contained in:
Ketchetwahmeegwun T. Southall 2022-01-30 15:49:05 -08:00
parent 8b5de4a2c1
commit c39e7ad54f

View File

@ -40,7 +40,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
let modeTimer = 0 let modeTimer = 0
let nightTime = 30 * 1000 let nightTime = 30 * 1000
let dayTime = 30 * 1000 let dayTime = 30 * 1000
let daysSurvived = 0 let daysSurvived = -1
let lastTime: number = performance.now() let lastTime: number = performance.now()
let player: AnimalEntity let player: AnimalEntity
@ -309,23 +309,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
player.turn() player.turn()
} }
// Add fake others progress()
// MOVE ME
for (let animal of ['turkey','nutria','deer','salamander','rabbit']) {
let count = 2 + Math.floor(Math.random() * 8)
for (let i = 0; i < count; i++) {
let spawn = getSpawnZone(animal)
if (!spawn) break
let bounds = spawn.bounds
let x = bounds[0] + Math.floor(Math.random() * bounds[2])
let y = bounds[1] + Math.floor(Math.random() * bounds[3])
let entity = new AnimalEntity(animals[animal])
addEntity(entity, 'objects', x, y)
}
}
// Add clock // Add clock
@ -365,8 +349,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
} else if (gameOverShown) { } else if (gameOverShown) {
updateGameOver() updateGameOver()
} }
} } else {
// Update clock // Update clock
{ {
//clockContainer.width = ctx.app.renderer.width //clockContainer.width = ctx.app.renderer.width
@ -392,6 +375,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
modeTimer = 0 modeTimer = 0
nightfall(true) nightfall(true)
} }
}
// Run world sim. // Run world sim.
while (elapsed >= 1/6) { while (elapsed >= 1/6) {
world.step(1/6) world.step(1/6)
@ -666,22 +650,47 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
l.colorMatrix.saturate(-0.75, true) l.colorMatrix.saturate(-0.75, true)
//l.colorMatrix.hue(160, true) //l.colorMatrix.hue(160, true)
} }
for (let e of entities) {
if (e instanceof AnimalEntity) {
e.turn()
}
}
} else { } else {
playSong('GGJ-HappyMusic') playSong('GGJ-HappyMusic')
for (let l of layers) { for (let l of layers) {
l.colorMatrix.reset() l.colorMatrix.reset()
} }
daysSurvived++
}
for (let e of entities) { for (let e of entities) {
if (e instanceof AnimalEntity) { if (e instanceof AnimalEntity) {
e.turn() e.turn()
} }
} }
progress()
}
isNight = b isNight = b
} }
let progress = () => {
daysSurvived++
for (let animal of ['turkey','nutria','deer','salamander','rabbit']) {
let count = 1 + Math.floor(Math.random() * daysSurvived)
for (let i = 0; i < count; i++) {
let spawn = getSpawnZone(animal)
if (!spawn) break
let bounds = spawn.bounds
let x = bounds[0] + Math.floor(Math.random() * bounds[2])
let y = bounds[1] + Math.floor(Math.random() * bounds[3])
let entity = new AnimalEntity(animals[animal])
addEntity(entity, 'objects', x, y)
}
}
}
nightfall(false) nightfall(false)
return { return {