Helios Lyons / Mbed 2 deprecated ELEC2645_Project_mc18hal

Dependencies:   mbed

Revision:
4:c644522ff9d9
Parent:
3:13fd052f79c6
diff -r 13fd052f79c6 -r c644522ff9d9 Canon/Canon.cpp
--- a/Canon/Canon.cpp	Thu Apr 02 14:30:31 2020 +0000
+++ b/Canon/Canon.cpp	Fri Apr 10 14:28:25 2020 +0000
@@ -1,5 +1,7 @@
 #include "Canon.h"
- 
+#include "Bitmap.h"
+#include <vector>
+
 Canon::Canon()
 {
  
@@ -10,11 +12,10 @@
  
 }
  
-void Canon::init(int x,int height,int width)
+void Canon::init(int y,int height,int width)
 {
     _y = y;  // y value on screen is fixed
-    _x = WIDTH/2 - width/2; // x depends on height of screen and width of paddle
-    _y = HEIGHT/2 - height/2;
+    _x = WIDTH/2 - width/2; // x depends on width of screen and width of canon
     _height = height;
     _width = width;
     _speed = 1;  // init speed, add in options – accessible?
@@ -29,7 +30,15 @@
 void Canon::draw(N5110 &lcd)
 {
     // draw canon in screen buffer – need to replace with a different shape
-    lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
+    //lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
+    static int sprite_data[] = {
+    0,0,0,1,1,0,0,0,
+    0,0,0,1,1,0,0,0,
+    1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1 
+    };
+    Bitmap canon_sprite(sprite_data, 8, 4);
+    canon_sprite.render(lcd, _x,_y);
 }
  
 void Canon::update(Direction d,float mag)
@@ -53,30 +62,35 @@
     }
 }
  
-void Canon::add_inv1_kill()
+int Canon::add_inv1_kill(int n)
 {
-    _inv1_kill++;
+    _inv1_kill = _inv1_kill + n;
+    return _inv1_kill;
 }
 
-void Canon::add_inv2_kill()
+int Canon::add_inv2_kill(int n)
 {
-    _inv2_kill++;
+    _inv2_kill = _inv2_kill + n;
+    return _inv2_kill;
 }
 
-void Canon::add_inv3_kill()
+int Canon::add_inv3_kill(int n)
 {
-    _inv3_kill++;
+    _inv3_kill = _inv3_kill + n;
+    return _inv3_kill;
 }
 
-void Canon::add_boss_kill()
+int Canon::add_boss_kill()
 {
     _boss_kill++;
+    return _boss_kill;
 }
 
 int Canon::get_total_kill()
 {
     _total_kill = _inv1_kill + _inv2_kill + _inv3_kill + _boss_kill;
     return _total_kill;
+}
 
 int Canon::get_score()
 {
@@ -97,9 +111,11 @@
 int Canon::remove_life()
 {
     _life--;
+    return _life;
 }
 
 int Canon::reset_life()
 {
     _life = 3;
+    return _life;
 }
\ No newline at end of file