Mortal Kombat Game ELEC2645

Dependencies:   mbed N5110 ShiftReg Joystick

Revision:
18:22bda659c70a
Parent:
17:928edcdd1058
--- a/Fighter.cpp	Tue Apr 27 23:21:21 2021 +0000
+++ b/Fighter.cpp	Thu Apr 29 22:40:08 2021 +0000
@@ -290,6 +290,14 @@
                 set_y(34);
             }
         }
+        if (buttonD.read() == 1) {       // computing jump move
+            draw(lcd);
+            add_y(-12);                   // add 12 to y position
+            int y_pos = get_y();
+            if (y_pos < 22) {           // to avoid sprite jumping more than 12 everytime user clicks D
+                set_y(22);
+                }
+        }
     }
     else if(x < 0.48) { //  joystick moved to the right
         // print  the  move_right animation, refresh, then print the 2nd move_right animation (toggling animations to create moving legs!)
@@ -316,9 +324,9 @@
         if (buttonD.read() == 1) {       // computing jump move
             move_right(lcd);
             add_y(-12);                   // add 12 to y position
-            add_x(5);
+            add_x(5);                     // add to x position
             int y_pos = get_y();
-            if (y_pos < 22) {           // to avoid sprite jumping more than 12 everytime they click D
+            if (y_pos < 22) {           // to avoid sprite jumping more than 12 everytime user clicks D
                 set_y(22);
             }
             if (x_pos >= 65) {   // code to stop fighter moving out of lcd screen while jumping!
@@ -349,7 +357,7 @@
         }
         // Guard if user presses button C
         if (buttonC.read() == 1) {
-            guard(lcd);  
+            guard(lcd);
         }
         // code to make fighter jump
         if (buttonD.read() == 1) {       // computing jump move for left movement
@@ -364,7 +372,7 @@
             add_x(5);
             }
         }
-        if (buttonD.read() == 0) {       // code to return fighter to ground 
+        if (buttonD.read() == 0) {       // code to return fighter to ground
             int y_pos = get_y();
             if (y_pos != 34) {
                 set_y(34);