Add nightfall; disable sound per default
This commit is contained in:
parent
d3e990a87c
commit
1583c1185a
|
@ -1,5 +1,6 @@
|
||||||
import { ContextI } from "../ContextI"
|
import { ContextI } from "../ContextI"
|
||||||
import { segments } from "../shared/segments"
|
import { segments } from "../shared/segments"
|
||||||
|
import { audio, playSong, disableSound, enableSound } from '../shared/audio'
|
||||||
import { StateI } from "./StateI"
|
import { StateI } from "./StateI"
|
||||||
import * as PIXI from 'pixi.js'
|
import * as PIXI from 'pixi.js'
|
||||||
import * as planck from 'planck'
|
import * as planck from 'planck'
|
||||||
|
@ -12,13 +13,25 @@ import { Entity } from "../live/Entity"
|
||||||
import { isPlayerEntity, PlayerEntity } from "../live/PlayerEntity"
|
import { isPlayerEntity, PlayerEntity } from "../live/PlayerEntity"
|
||||||
import { Action } from "../live/Action"
|
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 {
|
export interface Layer {
|
||||||
title: string
|
title: string
|
||||||
container: PIXI.Container
|
container: PIXI.Container
|
||||||
decorations: DecorationInstance[]
|
decorations: DecorationInstance[]
|
||||||
|
colorMatrix: PIXIMissingColorMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GameState(ctx: ContextI): StateI {
|
export function GameState(ctx: ContextI): StateI {
|
||||||
|
disableSound()
|
||||||
let world: planck.World = planck.World({
|
let world: planck.World = planck.World({
|
||||||
gravity: planck.Vec2(0, 0),
|
gravity: planck.Vec2(0, 0),
|
||||||
})
|
})
|
||||||
|
@ -45,7 +58,9 @@ export function GameState(ctx: ContextI): StateI {
|
||||||
title: l.title,
|
title: l.title,
|
||||||
container: new PIXI.Container(),
|
container: new PIXI.Container(),
|
||||||
decorations: [],
|
decorations: [],
|
||||||
|
colorMatrix: new PIXI.filters.ColorMatrixFilter()
|
||||||
}
|
}
|
||||||
|
layer.container.filters = [layer.colorMatrix]
|
||||||
layer.container.width = w.width
|
layer.container.width = w.width
|
||||||
layer.container.height = w.height
|
layer.container.height = w.height
|
||||||
|
|
||||||
|
@ -240,6 +255,28 @@ export function GameState(ctx: ContextI): StateI {
|
||||||
window.removeEventListener('keydown', keydown)
|
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 {
|
return {
|
||||||
enter,
|
enter,
|
||||||
leave,
|
leave,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user