Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Enemy.cpp
- Committer:
- ozy
- Date:
- 2021-04-17
- Revision:
- 1:3bdadf6f6dbd
- Child:
- 5:889ad974b64d
File content as of revision 1:3bdadf6f6dbd:
#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); } // ************************************************************************