Mortal Kombat Game ELEC2645

Dependencies:   mbed N5110 ShiftReg Joystick

Revision:
16:4a1d916d97c5
Parent:
15:7fd2d34f3be5
--- a/Enemy.cpp	Mon Apr 26 23:58:35 2021 +0000
+++ b/Enemy.cpp	Tue Apr 27 22:46:33 2021 +0000
@@ -269,34 +269,47 @@
 lcd.drawSprite(_x,_y,12,10,(int *)punchpunch);
 }
 
-void Enemy::randomize_moves(N5110 &lcd, int input) {
+int Enemy::randomize_moves(N5110 &lcd, int input) {
+    // return 1 to confirm collision
+    int collision = 0;
     int move_number = rand()%12;
     draw(lcd, input);
     // enemy state: looking to the right (input is 1)
     if(input == 1) {
         if (move_number == 0) {
             kick_right(lcd);
+            collision = 1;
         }
         else if (move_number == 1) {
             sword_right(lcd);
+            collision = 1;
         }
         else if (move_number == 2){
             twoway_punch(lcd);
+            collision = 1;
         }
-        else{draw(lcd, input);} // else have the enemy standing still but looking at fighter
+        else{draw(lcd, input); // else have the enemy standing still but looking at fighter
+            collision = 0;
+        }
     }
     else if(input == 0) { // enemy state: looking to the left 
         if (move_number == 0) {
             kick_left(lcd);
+            collision = 1;
         }
         else if (move_number == 1) {
             sword_left(lcd);
+            collision = 1;
         }
         else if (move_number == 2){
             twoway_punch(lcd);
+            collision = 1;
         }
-        else{draw(lcd, input);}
+        else{draw(lcd, input);
+            collision = 0;
+        }
     }
+    return collision;
 }