Target Library
Dependents: GameProject_Prototype
Diff: Target.cpp
- Revision:
- 10:45a0af3e607c
- Child:
- 11:5b2be6934e1b
diff -r 002ea306683d -r 45a0af3e607c Target.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Target.cpp Tue May 02 15:47:15 2017 +0000 @@ -0,0 +1,87 @@ +#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; +}