Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Diff: Fighter.cpp
- Revision:
- 9:8c840b08a633
- Parent:
- 8:e2e2eb4ea0ca
- Child:
- 10:e83899f11e8a
--- a/Fighter.cpp Thu Apr 22 18:33:23 2021 +0000 +++ b/Fighter.cpp Fri Apr 23 22:20:24 2021 +0000 @@ -1,6 +1,6 @@ #include "Fighter.h" #include "mbed.h" - +#include <stdlib.h> Fighter::Fighter() {} @@ -34,6 +34,7 @@ _y += y; } + void Fighter::draw(N5110 &lcd) { // drawing standing Fighter const int standsprite[12][10] = { @@ -312,6 +313,17 @@ lcd.refresh(); wait(0.3); } + if (buttonD.read() == 1) { // code for fighter to jump while running + add_y(-13); // temporarily increase y coordinates + add_x(10); // increment by 10 + move_right(lcd); + wait(0.15); + lcd.refresh(); + add_y(13); // return back to ground + draw(lcd); + wait(0.15); + lcd.refresh(); + } } else if(x > 0.52) { // joystick moved to the left @@ -345,5 +357,16 @@ lcd.refresh(); wait(0.3); } + if (buttonD.read() == 1) { // code for fighter to jump while running + add_y(-13); // temporarily increase y coordinates + add_x(-10); // decrement by 10 + move_left(lcd); + wait(0.15); + lcd.refresh(); + add_y(13); // return back to ground + draw(lcd); + wait(0.15); + lcd.refresh(); + } } } \ No newline at end of file