Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Enemy/Enemy.cpp
- Committer:
- Albutt
- Date:
- 2020-05-20
- Revision:
- 5:51fd6635141f
- Child:
- 6:546eba371942
File content as of revision 5:51fd6635141f:
#include "Enemy.h"
#include <Bitmap.h>
// nothing doing in the constructor and destructor
Enemy::Enemy()
{
}
Enemy::~Enemy()
{
}
void Enemy::init()
{
_x = 84;
_y = 48;
}
void Enemy::draw(N5110 &lcd)
{
lcd.drawRect(_x,_y,3,3,FILL_TRANSPARENT);
}
void Enemy::update(int player_x, int player_y)
{
if(_x<player_x){
_x++;
}
else if(_x > player_x){
_x--;
}
if(_y < player_y){
_y++;
}
else if (_y > player_y){
_y--;
}
}
int Enemy::get_x()
{
return _x;
}
int Enemy::get_y()
{
return _y;
}