ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Revision:
11:4e2eb64031a0
Parent:
10:d4fb12e9e7cd
--- a/TankL/TankL.cpp	Fri Apr 12 12:01:47 2019 +0000
+++ b/TankL/TankL.cpp	Sat Apr 13 16:31:43 2019 +0000
@@ -4,17 +4,17 @@
 1.4.19
 */
 #include "TankL.h"
-/*
+
 TankL::TankL()
 {
-
+    
 }
 
 TankL::~TankL()
 {
 
 }
-*/
+
 int TankL::get_position_x()
 {
     return _position_x;
@@ -53,7 +53,7 @@
 
 void TankL::move_position(int d)
 {
-    int slowness = 24 / _speed;
+    int slowness = 9 - _speed;
     int i = _move_counter % slowness;
     if (d > 0) {
         if (i == 0) {_position_x++;}
@@ -95,14 +95,16 @@
     };
     lcd.drawSprite(_position_x,42 - _position_y,6,10,(int *)tank_l_spr);
 
-    if (_angle < 18) {
-        const int turret_spr1[3][7] =   {
+    if (_angle >= 72 && _angle < 100 || _angle >= -260 && _angle < -255) {
+        const int turret_spr5[5][7] =   {
             { 0,0,1,0,0,0,0 },
-            { 0,1,1,1,1,1,1 },
+            { 0,0,1,0,0,0,0 },
+            { 0,0,1,0,0,0,0 },
+            { 0,1,1,1,0,0,0 },
             { 1,1,1,1,1,1,0 },                                                              
         };
-        lcd.drawSprite(2 + _position_x,42 - _position_y,3,7,(int *)turret_spr1);
-    } 
+        lcd.drawSprite(2 + _position_x,40 - _position_y,5,7,(int *)turret_spr5);
+    }
     else if (_angle >= 18 && _angle < 36) {  
         const int turret_spr2[3][7] =   {
             { 0,0,1,1,1,1,1 },
@@ -130,13 +132,11 @@
         lcd.drawSprite(2 + _position_x,41 - _position_y,4,7,(int *)turret_spr4);
     }
     else {
-        const int turret_spr5[5][7] =   {
-            { 0,0,1,0,0,0,0 },
+       const int turret_spr1[3][7] =   {
             { 0,0,1,0,0,0,0 },
-            { 0,0,1,0,0,0,0 },
-            { 0,1,1,1,0,0,0 },
+            { 0,1,1,1,1,1,1 },
             { 1,1,1,1,1,1,0 },                                                              
         };
-        lcd.drawSprite(2 + _position_x,40 - _position_y,5,7,(int *)turret_spr5);
-    }
+        lcd.drawSprite(2 + _position_x,42 - _position_y,3,7,(int *)turret_spr1);
+    } 
 }
\ No newline at end of file