Add temp nightfall; adjust action priority
This commit is contained in:
parent
cc7a736ae9
commit
f760065792
|
@ -31,7 +31,12 @@ export interface Layer {
|
|||
}
|
||||
|
||||
export function GameState(ctx: ContextI): StateI {
|
||||
disableSound()
|
||||
//disableSound()
|
||||
let isNight = false
|
||||
let modeTimer = 0
|
||||
let nightTime = 10 * 60
|
||||
let dayTime = 10 * 60
|
||||
|
||||
let world: planck.World = planck.World({
|
||||
gravity: planck.Vec2(0, 0),
|
||||
})
|
||||
|
@ -124,6 +129,14 @@ export function GameState(ctx: ContextI): StateI {
|
|||
let elapsed: number = 0
|
||||
let update = (delta: number) => {
|
||||
elapsed += delta
|
||||
modeTimer += delta
|
||||
if (isNight && modeTimer >= nightTime) {
|
||||
modeTimer = 0
|
||||
nightfall(false)
|
||||
} else if (!isNight && modeTimer >= dayTime) {
|
||||
modeTimer = 0
|
||||
nightfall(true)
|
||||
}
|
||||
// Run world sim.
|
||||
while (elapsed >= 1/60) {
|
||||
world.step(1/60)
|
||||
|
@ -217,7 +230,7 @@ export function GameState(ctx: ContextI): StateI {
|
|||
priority: v,
|
||||
})
|
||||
} else {
|
||||
action.priority += v
|
||||
action.priority = v
|
||||
if (action.priority <= 0) {
|
||||
desiredActions = desiredActions.filter(v=>v!==action)
|
||||
}
|
||||
|
@ -225,13 +238,13 @@ export function GameState(ctx: ContextI): StateI {
|
|||
}
|
||||
let keyup = (e: KeyboardEvent) => {
|
||||
if (e.key === 'ArrowLeft') {
|
||||
adjustAction('west', -1)
|
||||
adjustAction('west', 0)
|
||||
} else if (e.key === 'ArrowRight') {
|
||||
adjustAction('east', -1)
|
||||
adjustAction('east', 0)
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
adjustAction('north', -1)
|
||||
adjustAction('north', 0)
|
||||
} else if (e.key === 'ArrowDown') {
|
||||
adjustAction('south', -1)
|
||||
adjustAction('south', 0)
|
||||
}
|
||||
}
|
||||
let keydown = (e: KeyboardEvent) => {
|
||||
|
@ -255,8 +268,14 @@ export function GameState(ctx: ContextI): StateI {
|
|||
window.removeEventListener('keydown', keydown)
|
||||
}
|
||||
|
||||
let hookGamepad = () => {
|
||||
}
|
||||
let unhookGamepad = () => {
|
||||
}
|
||||
|
||||
let nightfall = (b: boolean) => {
|
||||
if (b) {
|
||||
playSong('GGJ-ScaryMusic')
|
||||
for (let l of layers) {
|
||||
//l.colorMatrix.brightness(0.25, false)
|
||||
l.colorMatrix.night(0.2, true)
|
||||
|
@ -273,6 +292,7 @@ export function GameState(ctx: ContextI): StateI {
|
|||
for (let e of entities) {
|
||||
}
|
||||
}
|
||||
isNight = b
|
||||
}
|
||||
|
||||
nightfall(false)
|
||||
|
|
Loading…
Reference in New Issue
Block a user