This is the description
Dependencies: mbed Menu Joystick
Diff: Enemy/Enemy.cpp
- Revision:
- 0:59cbc5800eb6
diff -r 000000000000 -r 59cbc5800eb6 Enemy/Enemy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Enemy/Enemy.cpp Mon Apr 27 14:04:30 2020 +0000 @@ -0,0 +1,74 @@ +#include "Enemy.h" +Enemy::Enemy(int mode) +{ + if ( mode == 0) + _blood = 1; + else if(mode == 1) + _blood = 2; + else if(mode == 2) + _blood = 3; +} +Enemy::~Enemy() +{ + +} +void Enemy::init(int sizeX,int sizeY) +{ + _sizeX = sizeX; + _sizeY = sizeY; + _x = rand()%(84-_sizeX); + _y = 0; + _speed = 1; +} +Vector2D Enemy::getPos() +{ + Vector2D p = {_x,_y}; + return p; +} +void Enemy::update() +{ + _y+=_speed; +} +void Enemy::setBlood(int harm){ + _blood-=harm; +} +void Enemy::draw(N5110 &lcd,int mode) +{ + int enemy[60] = { + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1 }; + int enemyNormal[60] = { + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1 }; + int enemyHard[60] = { + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1 }; + if(mode == 0){ + Bitmap sprite(enemy,_sizeY,_sizeX); + sprite.render(lcd,_x,_y); + }else if(mode == 1){ + Bitmap sprite(enemyNormal,_sizeY,_sizeX); + sprite.render(lcd,_x,_y); + }else if(mode == 2){ + Bitmap sprite(enemyHard,_sizeY,_sizeX); + sprite.render(lcd,_x,_y); + } +} +int Enemy::getBlood(){ + return _blood; +} +void Enemy::setSpeed(int speed){ + _speed = speed; +} +int Enemy::getSpeed(){ + return _speed; +} \ No newline at end of file