From 1583c1185aeef8e3334458101907c613532b9792 Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Sat, 29 Jan 2022 19:46:15 -0800 Subject: [PATCH] Add nightfall; disable sound per default --- Engine/src/states/Game.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Engine/src/states/Game.ts b/Engine/src/states/Game.ts index a9e6397..768dd82 100644 --- a/Engine/src/states/Game.ts +++ b/Engine/src/states/Game.ts @@ -1,5 +1,6 @@ import { ContextI } from "../ContextI" import { segments } from "../shared/segments" +import { audio, playSong, disableSound, enableSound } from '../shared/audio' import { StateI } from "./StateI" import * as PIXI from 'pixi.js' import * as planck from 'planck' @@ -12,13 +13,25 @@ import { Entity } from "../live/Entity" import { isPlayerEntity, PlayerEntity } from "../live/PlayerEntity" import { Action } from "../live/Action" +export interface PIXIMissingColorMatrix extends PIXI.Filter { + night(intensity: number, multiply: boolean): void + contrast(amount: number, multiply: boolean): void + brightness(amount: number, multiply: boolean): void + saturate(amount: number, multiply: boolean): void + hue(rotation: number, multiply: boolean): void + colorTone(desaturation: number, toned: number, lightColor: number, darkColor: number, multiple: boolean): void + reset(): void +} + export interface Layer { title: string container: PIXI.Container decorations: DecorationInstance[] + colorMatrix: PIXIMissingColorMatrix } export function GameState(ctx: ContextI): StateI { + disableSound() let world: planck.World = planck.World({ gravity: planck.Vec2(0, 0), }) @@ -45,7 +58,9 @@ export function GameState(ctx: ContextI): StateI { title: l.title, container: new PIXI.Container(), decorations: [], + colorMatrix: new PIXI.filters.ColorMatrixFilter() } + layer.container.filters = [layer.colorMatrix] layer.container.width = w.width layer.container.height = w.height @@ -240,6 +255,28 @@ export function GameState(ctx: ContextI): StateI { window.removeEventListener('keydown', keydown) } + let nightfall = (b: boolean) => { + if (b) { + for (let l of layers) { + //l.colorMatrix.brightness(0.25, false) + l.colorMatrix.night(0.2, true) + l.colorMatrix.saturate(-0.75, true) + //l.colorMatrix.hue(160, true) + } + for (let e of entities) { + } + } else { + playSong('GGJ-HappyMusic') + for (let l of layers) { + l.colorMatrix.reset() + } + for (let e of entities) { + } + } + } + + nightfall(false) + return { enter, leave,