ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18ajst

Dependencies:   mbed

Bullets/Bullets.cpp

Committer:
Albutt
Date:
2020-05-25
Revision:
12:c557b6c9b17a
Parent:
9:62fe47a1374f
Child:
14:2d7e41f46879

File content as of revision 12:c557b6c9b17a:

#include "Bullets.h"
Serial pcb(USBTX, USBRX);
Bullets::Bullets(int ex, int wy, int d)
{
    _dir = 0;
    _x = ex;
    _y = wy;
    _dir = d;
    //pcb.printf("Direction = %d", _dir);
}

Bullets::~Bullets()
{

}

void Bullets::draw(N5110 &lcd)
{   

    lcd.drawRect(_x,_y,1,1,FILL_BLACK);
}

void Bullets::update()
{
    if(_dir == 0){
    _y = _y-3;
    }
    else if (_dir == 1){
    _x = _x+3;
    }
    else if (_dir == 2){
    _y = _y+3;
    }
    else if (_dir == 3){
    _x = _x-3;
    }
}
int Bullets::get_x(){
    return _x;
    }
    
int Bullets::get_y(){
    return _y;
    }
    
void Bullets::dead(){
       _x = 2147483647;
       _y = 1000;
}