James Heavey
/
EL17JH
FINAL VERSION
Diff: Ball/Ball.cpp
- Revision:
- 136:04a2724f90cf
- Parent:
- 93:18f81996ea89
--- a/Ball/Ball.cpp Thu May 09 09:45:37 2019 +0000 +++ b/Ball/Ball.cpp Thu May 09 09:52:35 2019 +0000 @@ -30,35 +30,41 @@ } } + void Ball::draw(N5110 &lcd) // draw the ball at the specified location { lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); } + void Ball::update() // update the ball's position, based on its current velocity { _x += _velocity.x; _y += _velocity.y; } + void Ball::set_velocity(Vector2D v) // set the velocity in its x/y directions (used for collision velocity correction) { _velocity.x = v.x; _velocity.y = v.y; } + Vector2D Ball::get_velocity() // retrieve the ball's current velocities { Vector2D v = {_velocity.x,_velocity.y}; return v; } + Vector2D Ball::get_pos() // retrieve the ball's current coordinates { Vector2D p = {_x,_y}; return p; } + void Ball::set_pos(Vector2D p) // set the ball's coordinates (used for collision velocity correction) { _x = p.x;