diff --git a/src/Game/GameComponents.ts b/src/Game/GameComponents.ts index 724ecce..73fc282 100644 --- a/src/Game/GameComponents.ts +++ b/src/Game/GameComponents.ts @@ -1,6 +1,10 @@ -import { Layer, DrawSet } from "../Applet/Render"; -import { SparseStore } from "../Ecs/Data"; +import { KeyName } from "../Applet/Keyboard"; +import { DrawSet, Layer } from "../Applet/Render"; import { Data as EcsData } from "../Ecs/Components"; +import { copy, SparseStore } from "../Ecs/Data"; +import { DumbMotion } from "../Ecs/Location"; +import { INPUT_FREQUENCY, LockstepProcessor } from "../Ecs/Lockstep"; +import { Buttons } from "./Input"; export enum GamePhase { TITLE, @@ -110,3 +114,26 @@ export class Message { public timeout = 3 ) {} } + +export class Engine implements LockstepProcessor { + cloneState(old: Data) { + return new Data(old); + } + + compareInput(a: KeyName[], b: KeyName[]): boolean { + if (a.length != b.length) return false; + + let matches = true; + a.forEach((keyA, i) => { + if (keyA != b[i]) { + matches = false; + } + }); + + return matches; + } + + advanceState(state: Data, input: KeyName[]) { + DumbMotion(state, INPUT_FREQUENCY); + } +}