Create stub concrete lockstep engine

This commit is contained in:
Tangent Wantwight 2020-02-16 00:00:26 -05:00
parent 57c2364796
commit d321098555

View file

@ -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<KeyName[], Data> {
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);
}
}