Create stub concrete lockstep engine
This commit is contained in:
parent
57c2364796
commit
d321098555
1 changed files with 29 additions and 2 deletions
|
@ -1,6 +1,10 @@
|
||||||
import { Layer, DrawSet } from "../Applet/Render";
|
import { KeyName } from "../Applet/Keyboard";
|
||||||
import { SparseStore } from "../Ecs/Data";
|
import { DrawSet, Layer } from "../Applet/Render";
|
||||||
import { Data as EcsData } from "../Ecs/Components";
|
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 {
|
export enum GamePhase {
|
||||||
TITLE,
|
TITLE,
|
||||||
|
@ -110,3 +114,26 @@ export class Message {
|
||||||
public timeout = 3
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue