FreeRTOS Tetris
|
Object to represent a ball that bounces off walls. More...
#include <TUM_Ball.h>
Data Fields | |
signed short | x |
signed short | y |
float | f_x |
float | f_y |
float | dx |
float | dy |
float | max_speed |
unsigned int | colour |
signed short | radius |
callback_t | callback |
void * | args |
Object to represent a ball that bounces off walls.
A ball is created with a starting X and Y location (center of the ball), initial X and Y axis speeds (dx and dy respectively), as well as a limiting maximum speed, a colour and a radius. A callback function can be passed to the ball creation function createBall with the form void (*callback)(void), which is called each time the ball collides with a wall.
The absolute location of the ball is stored in the floats f_x and f_y, this is to avoid situation where the ball is moving so slowly that it cannot escape its current pixel as the rounding performed during integer mathematics is causing the ball to become trapped on a pixel.
The colour of the ball is a 24bit hex colour code of the format RRGGBB.
A ball is created with initial speeds (dx and dy) of zero. The speed of the ball must be set to a non-zero value using setBallSpeed before the ball will start to move.
void* ball::args |
Collision callback args
callback_t ball::callback |
Collision callback
unsigned int ball::colour |
Hex RGB colour of the ball
float ball::dx |
X axis speed in pixels/second
float ball::dy |
Y axis speed in pixels/second
float ball::f_x |
Absolute X location of ball
float ball::f_y |
Absolute Y location of ball
float ball::max_speed |
Maximum speed the ball is able to achieve in pixels/second
signed short ball::radius |
Radius of the ball in pixels
signed short ball::x |
X pixel coord of ball on screen
signed short ball::y |
Y pixel coord of ball on screen