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 nightTime = 30 * 1000
let dayTime = 30 * 1000
let daysSurvived = 0
let daysSurvived = -1
let lastTime: number = performance.now()
let player: AnimalEntity
@ -309,23 +309,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
player.turn()
}
// Add fake others
// 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)
}
}
progress()
// Add clock
@ -365,8 +349,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
} else if (gameOverShown) {
updateGameOver()
}
}
} else {
// Update clock
{
//clockContainer.width = ctx.app.renderer.width
@ -392,6 +375,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
modeTimer = 0
nightfall(true)
}
}
// Run world sim.
while (elapsed >= 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.hue(160, true)
}
for (let e of entities) {
if (e instanceof AnimalEntity) {
e.turn()
}
}
} else {
playSong('GGJ-HappyMusic')
for (let l of layers) {
l.colorMatrix.reset()
}
daysSurvived++
}
for (let e of entities) {
if (e instanceof AnimalEntity) {
e.turn()
}
}
progress()
}
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)
return {