Target Library
Dependents: GameProject_Prototype
Target.cpp
- Committer:
- ll14c4p
- Date:
- 2017-05-02
- Revision:
- 10:45a0af3e607c
- Child:
- 11:5b2be6934e1b
File content as of revision 10:45a0af3e607c:
#include "Target.h" Target::Target() { } Target::~Target() { } int sprite2[5][5] = { {1,0,1,0,1}, {0,1,0,1,0}, {1,0,1,0,1}, {0,1,0,1,0}, {1,0,1,0,1}, }; int n = 0; int b = 0; int v = 0; void Target::init() //Delete Int { } void Target::draw(N5110 &lcd) { _velocity.x = 0; _velocity.y = 2; if(_x <= -1){ n = 0; } if(_x >= 85){ n = 0; } if(_y <= -1){ n = 0; } if(_y >= 49){ n = 0; } if(n == 0){ _x = rand() % 79; _y = 0; //rand() % 20; n = n+1; } lcd.drawSprite(_x,_y,5,5,(int *)sprite2); } Vector2D Target::get_pos() { Vector2D Targetpos = {_x,_y}; //printf("Targetpos from Target = %f %f \n", Targetpos.x, Targetpos.y); return Targetpos; } void Target::update() { _x += _velocity.x; _y += _velocity.y; } void Target::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } Vector2D Target::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; }