harry rance
/
Revised_Space_Invaders
Harry Rance 200925395 Embedded Systems Project
Bullet.cpp
- Committer:
- harryrance
- Date:
- 2017-04-13
- Revision:
- 1:95d7dd44bb0d
- Child:
- 2:50feb42b982c
File content as of revision 1:95d7dd44bb0d:
#include "Bullet.h" Bullet::Bullet() { } Bullet::~Bullet() { } void Bullet::initialise(int x_origin, int y_origin, int speed, int button_check) { _x = x_origin; _y = y_origin; _button_check = button_check; _speed = speed; } void Bullet::check_button_press(Gamepad &pad) { if (pad.check_event(Gamepad::A_PRESSED)){ _button_check = 1; _speed = 1; } } void Bullet::draw(N5110 &lcd) { _y_origin = _y; _x_origin = _x; if (_button_check){ lcd.setPixel(_x_origin,_y_origin); lcd.setPixel(_x_origin,_y_origin-1); } } void Bullet::update() { _x += _velocity.x; _y -= _velocity.y; int direction = 0; if(direction == 0) { _velocity.y = _speed; } } void Bullet::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } void Bullet::set_position(Vector2D p) { _x = p.x; _y = p.y; } Vector2D Bullet::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } Vector2D Bullet::get_position() { Vector2D p = {_x,_y}; return p; }