Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Diff: Fighter.cpp
- Revision:
- 0:99b49fd71085
- Child:
- 1:3bdadf6f6dbd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Fighter.cpp Tue Apr 13 10:06:02 2021 +0000 @@ -0,0 +1,212 @@ +#include "Fighter.h" +#include "mbed.h" + + +Fighter::Fighter() {} + +void Fighter::draw(N5110 &lcd, float _x, float _y) { // drawing standing Fighter + + const int standsprite[12][10] = { + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,1,1,1,1,1,1,0,0 }, + { 0,0,1,0,1,1,0,1,0,0 }, + { 0,1,1,0,1,1,0,1,1,0 }, + { 0,1,0,0,1,1,0,0,1,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 0,0,1,0,0,0,0,1,0,0 }, + { 0,1,1,0,0,0,0,1,1,0 }, + { 0,1,0,0,0,0,0,0,1,0 }, + { 0,1,0,0,0,0,0,0,1,0 }, + }; + +lcd.drawSprite(_x,_y,12,10,(int *)standsprite); +} + +// ************************************************************************ + +void Fighter::move_left(N5110 &lcd, float _x, float _y){ + const int run_left[12][10] = { + { 0,0,1,1,1,0,0,0,0,0 }, + { 0,0,1,1,1,0,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,0,1,1,1,1,0,0 }, + { 1,1,1,0,1,1,0,1,1,0 }, + { 0,0,0,0,1,1,0,0,0,1 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 0,1,1,0,0,0,1,1,1,1 }, + { 0,0,1,1,0,0,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)run_left); +} + +// ************************************************************************ + +void Fighter::move_left2(N5110 &lcd, float _x, float _y){ +const int midrun_left[12][10] = { + { 0,0,1,1,1,0,0,0,0,0 }, + { 0,0,1,1,1,0,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,0,1,1,1,1,0,0 }, + { 1,1,1,0,1,1,0,1,1,0 }, + { 0,0,0,0,1,1,0,0,0,1 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 0,1,1,0,0,0,1,1,0,0 }, + { 0,0,1,1,0,0,0,1,1,0 }, + { 0,0,1,1,0,0,0,0,1,0 }, + { 0,0,0,1,0,0,0,0,1,1 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)midrun_left); +} + +// ************************************************************************ + +void Fighter::move_right(N5110 &lcd, float _x, float _y) { + + const int run_right[12][10] = { + { 0,0,0,0,0,1,1,1,0,0 }, + { 0,0,0,0,0,1,1,1,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,1,1,0,1,0,0 }, + { 0,1,1,0,1,1,0,1,1,1 }, + { 1,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 1,1,1,1,0,0,0,1,1,0 }, + { 0,0,0,0,0,0,1,1,0,0 }, + { 0,0,0,0,0,1,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)run_right); +} + +// ************************************************************************ + +void Fighter::move_right2(N5110 &lcd, float _x, float _y) { +const int midrun_right[12][10] = { + { 0,0,0,0,0,1,1,1,0,0 }, + { 0,0,0,0,0,1,1,1,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,1,1,0,1,0,0 }, + { 0,1,1,0,1,1,0,1,1,1 }, + { 1,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,1,1,0,1,1,0,0,0 }, + { 0,0,1,0,0,0,1,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)midrun_right); +} + +// ************************************************************************ + +void Fighter::kick_right(N5110 &lcd, float _x, float _y) { + const int kick[12][10] = { + { 0,1,1,0,0,0,0,0,0,0 }, + { 0,1,1,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,1 }, + { 0,0,1,1,1,0,0,0,1,1 }, + { 0,1,1,1,1,1,1,1,0,0 }, + { 0,1,0,0,1,1,1,0,0,0 }, + { 1,1,0,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,0,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,0,1,0,0,0,0,0,0 }, + { 0,0,1,1,0,0,0,0,0,0 }, + { 0,0,1,1,0,0,0,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)kick); +} + +// ************************************************************************ + +void Fighter::kick_left(N5110 &lcd, float _x, float _y) { + const int kick[12][10] = { + { 0,0,0,0,0,0,0,1,1,0 }, + { 0,0,0,0,1,1,0,1,1,0 }, + { 1,0,0,1,1,1,1,0,0,0 }, + { 1,1,0,0,0,1,1,1,0,0 }, + { 0,0,1,1,1,1,1,1,1,0 }, + { 0,0,0,1,1,1,0,0,1,0 }, + { 0,0,0,0,1,1,0,0,1,1 }, + { 0,0,0,0,0,1,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,0,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)kick); +} + +// ************************************************************************ + +void Fighter::punch_right(N5110 &lcd, float _x, float _y) { + const int punch[12][10] = { + { 0,0,0,0,1,1,0,0,0,1 }, + { 0,0,0,0,1,1,0,0,1,1 }, + { 0,0,1,1,1,1,0,1,1,0 }, + { 0,1,0,0,1,1,1,1,0,0 }, + { 0,1,1,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,1,0,0,1,1,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 0,0,1,0,0,0,1,0,0,0 }, + { 0,1,1,0,0,0,1,0,0,0 }, + { 1,1,0,0,0,1,1,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)punch); +} + +// ************************************************************************ + +void Fighter::punch_left(N5110 &lcd, float _x, float _y) { + const int punch[12][10] = { + { 1,0,0,0,1,1,0,0,0,0 }, + { 1,1,0,0,1,1,0,0,0,0 }, + { 0,1,1,0,1,1,1,1,0,0 }, + { 0,0,1,1,1,1,0,0,1,0 }, + { 0,0,0,0,1,1,0,1,1,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 0,0,0,1,0,0,0,1,0,0 }, + { 0,0,0,1,0,0,0,1,1,0 }, + { 0,0,0,1,1,0,0,0,1,1 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)punch); +} + +// ************************************************************************ + +void Fighter::guard(N5110 &lcd, float _x, float _y) { + const int guard[12][10] = { + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,0,1,1,0,1,0,0 }, + { 0,0,1,0,1,1,0,1,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,1,1,1,1,0,0 }, + { 0,1,0,0,0,0,0,0,1,0 }, + { 0,1,0,0,0,0,0,0,1,0 }, + { 0,1,0,0,0,0,0,0,1,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)guard); +} + + + + + +