ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18ajst

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;
    
}