Browse code

fix cpu crash

devnewton authored on 14/02/2018 21:29:12
Showing 2 changed files
... ...
@@ -17,13 +17,13 @@ export class CPU {
17 17
 
18 18
     moveToXY(x:number, y:number) {
19 19
         if(this.me.body.x < x) {
20
-            this.controls.goingLeft = true;
21
-        } else if(this.me.body.x < x) {
22 20
             this.controls.goingRight = true;
21
+        } else if(this.me.body.x < x) {
22
+            this.controls.goingLeft = true;
23 23
         }
24 24
         if(this.me.body.y < y) {
25 25
             this.controls.goingDown = true;
26
-        } else if(this.me.body.y < y) {
26
+        } else if(this.me.body.y > y) {
27 27
             this.controls.goingUp = true;
28 28
         }
29 29
     }
... ...
@@ -67,8 +67,8 @@ export class CPUControls extends AbstractControls {
67 67
     goingLeft: boolean = false;
68 68
     goingRight: boolean = false;
69 69
     hammerTime: boolean = false;
70
-    shootAngle: number = 0;
71
-    dashAngle: number = 0;
70
+    shootAngle: number = null;
71
+    dashAngle: number = null;
72 72
 
73 73
     reset() {
74 74
         this.goingUp = false;
... ...
@@ -76,8 +76,8 @@ export class CPUControls extends AbstractControls {
76 76
         this.goingLeft = false;
77 77
         this.goingRight = false;
78 78
         this.hammerTime = false;
79
-        this.shootAngle = 0;
80
-        this.dashAngle = 0;
79
+        this.shootAngle = null;
80
+        this.dashAngle = null;
81 81
     }
82 82
 
83 83
     isGoingUp(): boolean {