ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Bullet/Bullet.cpp

Committer:
el17m2h
Date:
2019-04-25
Revision:
19:5a7b0cdf013b
Parent:
18:9f40a2f8c2c5
Child:
23:9be87557b89a

File content as of revision 19:5a7b0cdf013b:

#include "Bullet.h"
Bullet::Bullet(){
}
Bullet::~Bullet(){
}

void Bullet::init(float dood_position_x, float dood_position_y){  
    _radius = 1;
    _position_x = dood_position_x; // initially in same position as doodler
    _position_y = dood_position_y;
}

void Bullet::draw(N5110 &lcd){
    lcd.drawCircle(_position_x, _position_y, _radius, FILL_BLACK);
}

void Bullet::update(float position_x, float position_y, float dood_pos_x, float dood_pos_y){
    _position_x = position_x;
    _position_y -= 3;
    if (_position_y < 0){ // reached end of screen
        _position_x = dood_pos_x;
        _position_y = dood_pos_y;
    }
}

float Bullet::get_position_x(){
    float p_x = _position_x; 
    return p_x;
}

float Bullet::get_position_y(){
    float p_y = _position_y;
    return p_y;
}

void Bullet::set_position(float pos_x, float pos_y){
    _position_x = pos_x; 
    _position_y = pos_y;
}