Ikenna Adrian Ozoemena 201157039

Dependencies:   mbed

Revision:
40:90c7a893d513
Parent:
39:7824f9080f59
Child:
42:ee13e1d103d8
Child:
43:500b8cff3715
--- a/Weapons/Weapons.cpp	Mon May 06 16:49:53 2019 +0000
+++ b/Weapons/Weapons.cpp	Tue May 07 10:01:34 2019 +0000
@@ -19,10 +19,7 @@
     _ship_ypos = ship_ypos;
 
 }
-
-
-
-void Weapons::draw(N5110 &lcd,Gamepad &pad,int shipno)
+void Weapons::draw(N5110 &lcd,Gamepad &pad,int shipno,Vector2D closest_enemy )
 {
     if(shipno == 0) {
         _velocity.x = 0; //Projectile doesn't move sideways.
@@ -50,11 +47,16 @@
             //}
         }
     }
-    if(shipno == 2){
+    if(shipno == 2) {
+        float rangex = (abs(_ship_xpos - closest_enemy.x));
+        float rangey = (abs(_ship_ypos - closest_enemy.y));
+        int distance = floor((rangex+rangey)/2);
+        if((A_button) == true && distance < 15) {
+            lcd.drawLine(_ship_xpos + 2,_ship_ypos + 2,closest_enemy.x + 2,closest_enemy.y + 2,FILL_BLACK);
         }
+    }
 }
 
-
 void Weapons::update()
 {
     _x = _x + _velocity.x;