Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Diff: Enemy.cpp
- Revision:
- 1:3bdadf6f6dbd
- Child:
- 5:889ad974b64d
diff -r 99b49fd71085 -r 3bdadf6f6dbd Enemy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Enemy.cpp Sat Apr 17 11:38:39 2021 +0000 @@ -0,0 +1,188 @@ +#include "Enemy.h" +#include "mbed.h" + +Enemy::Enemy() {} + +void Enemy::draw(N5110 &lcd, float _x, float _y) { + + 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,1,0 }, + { 0,1,0,0,1,1,0,0,1,0 }, + { 0,1,0,0,1,1,0,1,1,1 }, + { 0,0,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 Enemy::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,1,1,0 }, + { 0,0,1,0,1,1,0,0,1,0 }, + { 1,1,1,0,1,1,0,1,1,1 }, + { 0,0,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,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 Enemy::move_left2(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,1,1,0 }, + { 0,0,1,0,1,1,0,0,1,0 }, + { 1,1,1,0,1,1,0,1,1,1 }, + { 0,0,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,0,1,1,1,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,0,1,0,1,0,0,0 }, + { 0,0,0,1,0,0,0,1,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)run_left); +} + +// ************************************************************************ + +void Enemy::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,1,0,1,0 }, + { 0,1,1,0,1,1,0,1,1,1 }, + { 0,0,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 }, + { 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 Enemy::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,1,0,1,0 }, + { 0,1,1,0,1,1,0,1,1,1 }, + { 0,0,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,0,1,1,1,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,0,1,0,0,0,0 }, + { 0,0,1,0,0,0,1,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)midrun_right); +} + + +void Enemy::sword_right(N5110 &lcd, float _x, float _y) { + const int swordsprite[12][10] = { + { 0,0,1,1,1,1,0,0,0,0 }, + { 1,0,1,1,1,1,0,0,0,0 }, + { 1,0,0,1,1,0,0,0,0,0 }, + { 1,1,0,1,1,0,1,0,0,0 }, + { 0,1,1,1,1,1,1,1,1,1 }, + { 0,0,0,1,1,0,1,0,0,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,1,0,0,1,1,0,0,0 }, + { 0,1,0,0,1,1,0,0,0,0 }, + { 1,1,0,0,1,0,0,0,0,0 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)swordsprite); +} + +// ************************************************************************ + + +void Enemy::sword_left(N5110 &lcd, float _x, float _y) { + const int swordsprite[12][10] = { + { 0,0,0,0,1,1,1,1,0,0 }, + { 0,0,0,0,1,1,1,1,0,1 }, + { 0,0,0,0,0,1,1,0,0,1 }, + { 0,0,0,1,0,1,1,0,1,1 }, + { 1,1,1,1,1,1,1,1,1,0 }, + { 0,0,0,1,0,1,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,0,1,1,1,1,0,0 }, + { 0,0,0,1,1,0,0,1,1,0 }, + { 0,0,0,0,1,1,0,0,1,0 }, + { 0,0,0,0,0,1,0,0,1,1 }, + }; +lcd.drawSprite(_x,_y,12,10,(int *)swordsprite); +} + +// ************************************************************************ + + +void Enemy::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,1,0,1,1,0,0,0,0 }, + { 0,1,0,0,1,0,0,0,0,0 }, + { 0,1,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 Enemy::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,1,1,1 }, + { 0,0,0,0,0,1,0,0,1,0 }, + { 0,0,0,0,1,1,0,0,1,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); +} + +// ************************************************************************ + + +