Hacky key control

This commit is contained in:
Tangent Wantwight 2020-03-26 00:29:24 -04:00
parent e3ddadadda
commit 3a2bc5654e
2 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,7 @@
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 { copy, Join, SparseStore } from "../Ecs/Data";
import { DumbMotion } from "../Ecs/Location";
import { INPUT_FREQUENCY, LockstepProcessor } from "../Ecs/Lockstep";
import { Buttons } from "./Input";
@ -135,5 +135,15 @@ export class Engine implements LockstepProcessor<KeyName[], Data> {
advanceState(state: Data, input: KeyName[]) {
DumbMotion(state, INPUT_FREQUENCY);
Join(state, "location").forEach(([location]) => {
let dir = 0;
if(input.indexOf("left") != -1) {
dir -= 1;
}
if(input.indexOf("right") != -1) {
dir += 1;
}
location.VAngle = dir * 0.01;
});
}
}

View File

@ -40,7 +40,6 @@ export class Main extends LockstepClient<KeyName[], Data> {
location: new Location({
X: 200,
Y: 200,
VAngle: 0.02,
}),
bounds: new Polygon([-30, 0, 30, 0, 0, 40]),
renderBounds: new RenderBounds("#a0f", 0),