Hacky key control
This commit is contained in:
parent
e3ddadadda
commit
3a2bc5654e
2 changed files with 11 additions and 2 deletions
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue