From 3a2bc5654e26d5abc3a58fe55fcd53897d970753 Mon Sep 17 00:00:00 2001
From: Tangent Wantwight <tangent128@gmail.com>
Date: Thu, 26 Mar 2020 00:29:24 -0400
Subject: [PATCH] Hacky key control

---
 src/Game/GameComponents.ts | 12 +++++++++++-
 src/Game/Main.ts           |  1 -
 2 files changed, 11 insertions(+), 2 deletions(-)

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<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;
+        });
     }
 }
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<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),