ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Revision:
7:a3ccabdebe2e
Child:
8:d4e419dad90f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TankL/TankL.cpp	Tue Apr 09 17:09:29 2019 +0000
@@ -0,0 +1,75 @@
+/* TankL.cpp
+Produces tank on the left side of the
+lcd and dictates it's movement
+1.4.19
+*/
+
+#include "TankL.h"
+/*
+TankL::TankL()
+{
+
+}
+
+TankL::~TankL()
+{
+
+}
+*/
+void TankL::draw(N5110 &lcd)
+{
+    const int tank_l_spr[6][10] =   {
+        { 0,0,0,1,1,1,0,0,0,0 },
+        { 0,0,1,1,1,1,1,0,0,0 },
+        { 0,0,1,1,1,1,1,1,1,0 },
+        { 1,1,1,1,1,1,1,1,1,1 },
+        { 1,0,1,0,1,0,1,0,1,0 },
+        { 0,1,0,1,0,1,0,1,0,0 },                                                                
+    };
+    lcd.drawSprite(_position_x,42 - _position_y,6,10,(int *)tank_l_spr);
+}
+
+void TankL::set_position(int x, int y)
+{
+    _position_x = x;
+    _position_y = y;
+}
+
+int TankL::get_position_x()
+{
+    return _position_x;
+}
+
+int TankL::get_position_y()
+{
+    return _position_y;
+}
+
+int TankL::get_hitbox(int i)
+{
+    return _hitbox[i];
+}
+
+void TankL::set_health(int h)
+{
+    _health = h;   
+}
+
+void TankL::lose_health()
+{
+    _health--;
+/*    if (_health <= 0) right player wins
+{} */
+}
+
+void TankL::generate_hitbox()
+{
+    int i = 0;
+    for (int i0 = 0; i0 < 4; i0++) {
+    
+        for (int i1 = 1; i1 < 11; i1++) {
+        _hitbox[i] = (i0 + _position_y) * 84 + _position_x + i1;
+        i++;
+        }
+    }
+}
\ No newline at end of file