From 2d313da67e531e039e9ed93087cd3cab5f461d6d Mon Sep 17 00:00:00 2001 From: kts of kettek <kts@kettek.net> Date: Sun, 30 Jan 2022 16:32:48 -0800 Subject: [PATCH] Use warning sound --- Engine/src/states/Game.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Engine/src/states/Game.ts b/Engine/src/states/Game.ts index 7191479..3b35b58 100644 --- a/Engine/src/states/Game.ts +++ b/Engine/src/states/Game.ts @@ -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()