Use warning sound

This commit is contained in:
Ketchetwahmeegwun T. Southall 2022-01-30 16:32:48 -08:00
parent 7b78689efa
commit 2d313da67e

View File

@ -1,6 +1,6 @@
import { ContextI } from "../ContextI"
import { segments } from "../shared/segments"
import { audio, playSong, disableSound, enableSound, stopSong } from '../shared/audio'
import { audio, playSong, disableSound, enableSound, stopSong, playSound } from '../shared/audio'
import { StateI } from "./StateI"
import * as PIXI from 'pixi.js'
import * as planck from 'planck'
@ -43,6 +43,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
let daysSurvived = -1
let lastTime: number = performance.now()
let player: AnimalEntity
let nightIndicated = false
// Game Over screenie
let gameOverShown = false
@ -376,6 +377,12 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
clockSunSprite.container.angle -= 230
}
// If we're getting within 3 seconds of night, play audio.
if (!isNight && !nightIndicated && modeTimer >= nightTime - 5000) {
playSound('action/warning', 1)
nightIndicated = true
}
if (isNight && modeTimer >= nightTime) {
modeTimer = 0
nightfall(false)
@ -570,7 +577,6 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
let desiredActions: Action[] = []
let keyup = (e: KeyboardEvent) => {
console.log(e)
if (e.key === 'ArrowLeft' || e.key === 'h') {
desiredActions = adjustAction(desiredActions, 'west', 0)
} else if (e.key === 'ArrowRight' || e.key === 'l') {
@ -665,6 +671,7 @@ export function GameState(ctx: ContextI, selectedAnimal: string, selectedSegment
}
}
} else {
nightIndicated = false
playSong('GGJ-HappyMusic')
for (let l of layers) {
l.colorMatrix.reset()