ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18jkeo

Dependencies:   mbed

Revision:
21:970807533b10
Parent:
20:0b6f1cfc5be6
Child:
24:ff5af5a013b5
--- a/Ship/Ship.cpp	Fri May 01 19:41:24 2020 +0000
+++ b/Ship/Ship.cpp	Tue May 12 15:33:50 2020 +0000
@@ -20,18 +20,20 @@
     Width = width;
     Speed = 0;
     Life = true;
+    ship_bullet_vector.init();
 }
 
 
 void Ship::render(N5110 &lcd)
 { 
+    ship_bullet_vector.render(lcd);
     if(Life == true){
     lcd.drawRect(X,Y,Width,Height,FILL_BLACK);
     lcd.refresh();
     }
 }
 
-void Ship::update(Direction d,float mag)
+void Ship::update(Direction d,float mag, Gamepad &pad, N5110 &lcd, int counter)
 {
     Speed = int(mag*10.0f);  
 
@@ -60,6 +62,10 @@
     if (X > WIDTH - Width - 1) {
         X = WIDTH - Width - 1;
     }
+    ship_bullet_vector.update(pad,lcd,X+4,Y,counter);
+    if(Life == false){
+        pad.leds_on();
+        }
 }
 
 Vector2D Ship::get_position() {
@@ -80,7 +86,18 @@
 void Ship::set_life(bool life){
     Life = life;
     }
+    
+bool Ship::get_life(){
+    return Life;
+    }
 
+vector<Bullet> Ship::get_bullet_vector(){
+    vector<Bullet> v = ship_bullet_vector.get_vector();
+    return v;
+}
     
+void Ship::set_bullet_hit(int i, bool hit){
+    ship_bullet_vector.set_hit(i,hit);
+}
     
     
\ No newline at end of file