diff --git a/src/Game/GameComponents.ts b/src/Game/GameComponents.ts index 73fc282..f73fb01 100644 --- a/src/Game/GameComponents.ts +++ b/src/Game/GameComponents.ts @@ -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 { 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; + }); } } diff --git a/src/Game/Main.ts b/src/Game/Main.ts index 86c5367..757221a 100644 --- a/src/Game/Main.ts +++ b/src/Game/Main.ts @@ -40,7 +40,6 @@ export class Main extends LockstepClient { location: new Location({ X: 200, Y: 200, - VAngle: 0.02, }), bounds: new Polygon([-30, 0, 30, 0, 0, 40]), renderBounds: new RenderBounds("#a0f", 0),