Class containing methods to draw a ball within the maze game with the specified position, size and fill style parameters.
Diff: Ball.cpp
- Revision:
- 1:ba8bb10ebd5a
- Parent:
- 0:4c58ed26b6ea
- Child:
- 2:bcb96ab2848b
diff -r 4c58ed26b6ea -r ba8bb10ebd5a Ball.cpp --- a/Ball.cpp Tue Apr 04 10:30:48 2017 +0000 +++ b/Ball.cpp Fri Apr 07 10:29:08 2017 +0000 @@ -18,20 +18,29 @@ } -void Ball::draw(N5110 &lcd, int x, int y, int radius) -{ - // lcd.clear(); - float _x = x; - float _y = y; - float _radius = radius; +void Ball::init(int x, int y, int radius) +{ + // properties of ball are set with values passed down from engine + _x = x; + _y = y; + _radius = radius; - printf("INPUT: x = %i, y = %i, radius = %i \n", x, y, radius); - printf("DRAW FUNCTION: x = %f, y = %f, radius = %f \n", _x, _y, _radius); - // lcd.drawCircle(x,y,radius,filltype); + velocity.x = SPEED; // arbitrary speed of moving 1 pixel per update + velocity.y = SPEED; - // lcd.drawCircle(43, 21, 5, FILL_TRANSPARENT); - lcd.drawCircle(_x, _y, _radius, FILL_TRANSPARENT); - lcd.refresh(); + // printf("INPUT: x = %i, y = %i, radius = %i \n", x, y, radius); + // printf("DRAW FUNCTION: x = %f, y = %f, radius = %f \n", _x, _y, _radius); } +void Ball::update() +{ + // new coordinates for the centre of the ball + _x += velocity.x; + _y += velocity.y; + +} +void Ball::draw(N5110 &lcd) +{ + lcd.drawCircle(_x, _y, _radius, FILL_BLACK); +} \ No newline at end of file