Target Library
Dependents: GameProject_Prototype
Diff: Target.cpp
- Revision:
- 13:828ede9cf8a5
- Parent:
- 12:855610bdba49
diff -r 855610bdba49 -r 828ede9cf8a5 Target.cpp --- a/Target.cpp Wed May 03 13:33:40 2017 +0000 +++ b/Target.cpp Thu May 04 08:34:51 2017 +0000 @@ -10,6 +10,7 @@ } +//Target Sprite. int sprite2[8][10] = { {1,1,1,1,1,1,1,1,1,1}, {1,1,0,1,0,1,0,1,0,1}, @@ -35,6 +36,14 @@ //_velocity.x = 1; _velocity.y = 1; + //Sideways velocity is randomised. + + + //Remember to seed + + + + /* int random = rand() % 3; if(random == 0){ _velocity.x = 0; @@ -50,6 +59,8 @@ } */ + //Resets target position if it reaches the bottom of the screen. + //Also prevents target from going out of the side of the screen. if(_x <= -1){ _x = 0; } @@ -66,12 +77,12 @@ n = n+1; } - lcd.drawSprite(_x,_y,8,10,(int *)sprite2); + lcd.drawSprite(_x,_y,8,10,(int *)sprite2); //Function to draw the sprite. } -Vector2D Target::get_pos() +Vector2D Target::get_pos() //Obtains the X and Y coordinate of the target. { Vector2D Targetpos = {_x,_y}; //printf("Targetpos from Target = %f %f \n", Targetpos.x, Targetpos.y); @@ -87,17 +98,6 @@ _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; -} void Target::set_pos(Vector2D p) {