Ikenna Adrian Ozoemena 201157039

Dependencies:   mbed

Revision:
42:ee13e1d103d8
Parent:
41:e1fa36c0492e
--- a/Enemy/Enemy.cpp	Wed May 08 09:22:16 2019 +0000
+++ b/Enemy/Enemy.cpp	Wed May 08 11:18:40 2019 +0000
@@ -30,7 +30,7 @@
     {0,0,0,0,1,0,1,0,0,0,0},
     {0,0,0,0,0,1,0,0,0,0,0},
 };
-void Enemy::init(int shno, int seno)
+void Enemy::init(int shno, int seno,N5110 *lcd, Gamepad *pad)
 {
     // initialize seeker
      _seekerPos[0].x = rand_no(68);
@@ -49,13 +49,14 @@
     _shooterSpeed[1].y = 1;
     _shooterSpeed[2].y = 1;
     // for now just starting them spaced apart add randomizer later
-
     _shooterPos[0].x = rand_no(68);
     _shooterPos[0].y = 1;
     _shooterPos[1].x = rand_no(68);
     _shooterPos[1].y = 1;
     _shooterPos[2].x = rand_no(68);
     _shooterPos[2].y = 1;
+    _lcd = lcd;
+    _pad = pad;
 
 }
 void Enemy::set_noshooters(int no_shooters)
@@ -67,37 +68,37 @@
     _seno = no_seekers;
 }
 // Draw the ship ***Note: figure out how to change ship type e.g from basic to devotion
-void Enemy::draw_seeker(N5110 &lcd)    
+void Enemy::draw_seeker()    
 {   
     switch (_seno) {
         case 1:
-            lcd.drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
+            _lcd->drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
             break;
         case 2:
-            lcd.drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
-            lcd.drawSprite( _seekerPos[1].x, _seekerPos[1].y,7,9,(int *)seeker);
+            _lcd->drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
+            _lcd->drawSprite( _seekerPos[1].x, _seekerPos[1].y,7,9,(int *)seeker);
             break;
         case 3:
-            lcd.drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
-            lcd.drawSprite( _seekerPos[1].x, _seekerPos[1].y,7,9,(int *)seeker);
-            lcd.drawSprite( _seekerPos[2].x, _seekerPos[2].y,7,9,(int *)seeker);
+            _lcd->drawSprite( _seekerPos[0].x, _seekerPos[0].y,7,9,(int *)seeker);
+            _lcd->drawSprite( _seekerPos[1].x, _seekerPos[1].y,7,9,(int *)seeker);
+            _lcd->drawSprite( _seekerPos[2].x, _seekerPos[2].y,7,9,(int *)seeker);
             break;
     }
 }
-void Enemy::draw_shooter(N5110 &lcd)
+void Enemy::draw_shooter()
 {
     switch (_shno) {
         case 1:
-            lcd.drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
+            _lcd->drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
             break;
         case 2:
-            lcd.drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
-            lcd.drawSprite(_shooterPos[1].x,_shooterPos[1].y,10,11,(int *)shooter);
+            _lcd->drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
+            _lcd->drawSprite(_shooterPos[1].x,_shooterPos[1].y,10,11,(int *)shooter);
             break;
         case 3:
-            lcd.drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
-            lcd.drawSprite(_shooterPos[1].x,_shooterPos[1].y,10,11,(int *)shooter);
-            lcd.drawSprite(_shooterPos[2].x,_shooterPos[2].y,10,11,(int *)shooter);
+            _lcd->drawSprite(_shooterPos[0].x,_shooterPos[0].y,10,11,(int *)shooter);
+            _lcd->drawSprite(_shooterPos[1].x,_shooterPos[1].y,10,11,(int *)shooter);
+            _lcd->drawSprite(_shooterPos[2].x,_shooterPos[2].y,10,11,(int *)shooter);
             break;
     }
 }
@@ -237,7 +238,7 @@
     
 }
 
-void Enemy::draw_shw1(N5110 &lcd,Gamepad &pad)
+void Enemy::draw_shw1()
 {
     _shooterWSpeed[0].x = 0; //Projectile doesn't move sideways.
     _shooterWSpeed[0].y = 2; //Projectile moves upwards on screen.
@@ -252,10 +253,10 @@
         _shooterWPos[0].y = _shooterPos[0].y + 11;
         _reset[0] = _reset[0] + 1;
     }
-    lcd.drawRect(_shooterWPos[0].x,_shooterWPos[0].y,1,1,FILL_BLACK);
+    _lcd->drawRect(_shooterWPos[0].x,_shooterWPos[0].y,1,1,FILL_BLACK);
 // printf("Ship x and y pos, reset = %d , %d ,%d \n", _ship_xpos, _ship_ypos, reset);
 }
-void Enemy::draw_shw2(N5110 &lcd,Gamepad &pad)
+void Enemy::draw_shw2()
 {
     _shooterWSpeed[1].x = 0; //Projectile doesn't move sideways.
     _shooterWSpeed[1].y = 5; //Projectile moves upwards on screen.
@@ -270,10 +271,10 @@
         _shooterWPos[1].y = _shooterPos[1].y + 11;
         _reset[1] = _reset[1] + 1;
     }
-    lcd.drawRect(_shooterWPos[1].x,_shooterWPos[1].y,1,1,FILL_BLACK);
+    _lcd->drawRect(_shooterWPos[1].x,_shooterWPos[1].y,1,1,FILL_BLACK);
     // printf("Ship x and y pos, reset = %d , %d ,%d \n", _ship_xpos, _ship_ypos, reset);
 }
-void Enemy::draw_shw3(N5110 &lcd,Gamepad &pad)
+void Enemy::draw_shw3()
 {
     _shooterWSpeed[2].x = 0; //Projectile doesn't move sideways.
     _shooterWSpeed[2].y = 3; //Projectile moves upwards on screen.
@@ -288,22 +289,22 @@
         _shooterWPos[2].y = _shooterPos[2].y + 11;
         _reset[2] = _reset[2] + 1;
     }
-    lcd.drawRect(_shooterWPos[2].x,_shooterWPos[2].y,1,1,FILL_BLACK);
+    _lcd->drawRect(_shooterWPos[2].x,_shooterWPos[2].y,1,1,FILL_BLACK);
 }
-void Enemy::draw_shw(N5110 &lcd,Gamepad &pad)
+void Enemy::draw_shw()
 {
     switch (_shno) {
         case 1:
-            draw_shw1(lcd,pad);
+            draw_shw1();
             break;
         case 2:
-            draw_shw1(lcd,pad);
-            draw_shw2(lcd,pad);
+            draw_shw1();
+            draw_shw2();
             break;
         case 3:
-            draw_shw1(lcd,pad);
-            draw_shw2(lcd,pad);
-            draw_shw3(lcd,pad);
+            draw_shw1();
+            draw_shw2();
+            draw_shw3();
             break;
     }
 }