ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Revision:
20:5b4b3bf5795c
Parent:
19:3316dba9787e
Child:
21:628fb703188f
--- a/RosenEngine/RosenEngine.cpp	Sat Apr 13 19:12:05 2019 +0000
+++ b/RosenEngine/RosenEngine.cpp	Sun Apr 14 06:25:16 2019 +0000
@@ -18,7 +18,7 @@
     // initialise the game parameters
     _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos);
     // place seeker above the ship
-    _enemy.init(ship_xpos, 0);
+    _enemy.init(44, 0);
     _menu.init(16);
     _health.init(_xcursor);
 
@@ -77,7 +77,9 @@
         _weapons.update();
     }
     // _menu.update(_d);
+
     check_enemy_ship_collision();
+    // printf("collision check complete");
 }
 void RosenEngine::get_pos()
 {
@@ -120,31 +122,36 @@
     bool ycol = false;
 
     // create an array of all x positions for the ship sprite i.e along its width (ship_x)
-    for(int countx = 0; countx>=9; countx=countx+1) {
+    for(int countx = 0; countx<=9; countx=countx+1) {
         ship_x[countx] = ship_pos.x + countx;
         seeker_x[countx] = seeker_pos.x + countx;
+         //printf("ship_x = %d, seeker_x = %d\n", ship_x[countx], seeker_x[countx]);
     }
 
     // create an array of all y positions for the ship sprite i.e along its height (ship_y)
-    for(int county = 0; county>=6; county=county+1) {
+    for(int county = 0; county<=6; county=county+1) {
         ship_y[county] = ship_pos.y + county;
         seeker_y[county] = seeker_pos.y + county;
+         //printf("ship_y = %d, seeker_y = %d\n", ship_y[county], seeker_y[county]);
     }
     // check all values of ship position against all values of seekers x position
-    for(int nx = 0; nx>=9; nx=nx+1) {
-        for(int mx = 0; mx>=9; mx=mx+1) {
+    for(int nx = 0; nx<=9; nx=nx+1) {
+        for(int mx = 0; mx<=9; mx=mx+1) {
             if(ship_x[nx] == seeker_x[mx]) {
                 xcol = true;
             }
         }
     }
-    for(int ny = 0; ny>=6; ny=ny+1) {
-        for(int my = 0; my>=9; my=my+1) {
+    for(int ny = 0; ny<=6; ny=ny+1) {
+        for(int my = 0; my<=6; my=my+1) {
             if(ship_y[ny] == seeker_y[my]) {
                 ycol = true;
             }
         }
     }
+
+
+     printf("xcol = %d, ycol = %d\n", xcol, ycol);
     if(xcol == true && ycol == true) {
         _health.update(1);
         _enemy.reset_seeker();