FreeRTOS Tetris
TUM_Ball.h
Go to the documentation of this file.
1 
25 #ifndef __TUM_BALL_H__
26 #define __TUM_BALL_H__
27 
46 typedef void (*callback_t)(void *args);
47 
68 typedef struct ball {
69  signed short x;
70  signed short y;
72  float f_x;
73  float f_y;
75  float dx;
76  float dy;
78  float max_speed;
81  unsigned int colour;
83  signed short radius;
86  void *args;
87 } ball_t;
88 
113 typedef struct wall {
114  signed short x1;
115  signed short y1;
117  signed short w;
118  signed short h;
120  signed short x2;
121  signed short y2;
123  float dampening;
126  unsigned int colour;
129  void *args;
130 } wall_t;
131 
151 ball_t *createBall(signed short initial_x, signed short initial_y,
152  unsigned int colour, signed short radius, float max_speed,
153  callback_t callback, void *args);
154 
169 wall_t *createWall(signed short x1, signed short y1, signed short w,
170  signed short h, float dampening, unsigned int colour,
171  callback_t callback, void *args);
172 
182 #define SET_WALL_X 0b1
183 
184 #define SET_WALL_Y 0b10
185 
186 #define SET_WALL_WIDTH 0b100
187 
188 #define SET_WALL_HEIGHT 0b1000
189 
190 #define SET_WALL_AXES SET_WALL_X | SET_WALL_Y
191 
192 #define SET_WALL_SIZE SET_WALL_WIDTH | SET_WALL_HEIGHT
193 
194 #define SET_WALL_ALL SET_WALL_AXES | SET_WALL_SIZE
195 
210 void setWallProperty(wall_t *wall, signed short x, signed short y,
211  signed short width, signed short height,
212  unsigned char flags);
213 
226 #define SET_BALL_SPEED_X 0b1
227 
233 #define SET_BALL_SPEED_Y 0b10
234 
240 #define SET_BALL_SPEED_MAX 0b100
241 
247 #define SET_BALL_SPEED_AXES SET_BALL_SPEED_X | SET_BALL_SPEED_Y
248 
255 #define SET_BALL_SPEED_ALL SET_BALL_SPEED_AXES | SET_BALL_SPEED_MAX
256 
270 void setBallSpeed(ball_t *ball, float dx, float dy, float max_speed,
271  unsigned char flags);
272 
282 void setBallLocation(ball_t *ball, signed short x, signed short y);
283 
294 signed char checkBallCollisions(ball_t *ball, callback_t callback, void *args);
295 
312 void updateBallPosition(ball_t *ball, unsigned int milli_seconds);
313 
315 #endif
wall_t
struct wall wall_t
Object to represent a wall that balls bounce off of.
wall::y1
signed short y1
Definition: TUM_Ball.h:115
callback_t
void(* callback_t)(void *args)
Callback function attached to an object.
Definition: TUM_Ball.h:46
ball::dy
float dy
Definition: TUM_Ball.h:76
ball::x
signed short x
Definition: TUM_Ball.h:69
setWallProperty
void setWallProperty(wall_t *wall, signed short x, signed short y, signed short width, signed short height, unsigned char flags)
Sets one or more properties of a wall.
Definition: TUM_Ball.c:53
ball::callback
callback_t callback
Definition: TUM_Ball.h:85
wall::x1
signed short x1
Definition: TUM_Ball.h:114
setBallSpeed
void setBallSpeed(ball_t *ball, float dx, float dy, float max_speed, unsigned char flags)
Sets the speed of the ball.
Definition: TUM_Ball.c:99
ball::y
signed short y
Definition: TUM_Ball.h:70
ball_t
struct ball ball_t
Object to represent a ball that bounces off walls.
ball::f_y
float f_y
Definition: TUM_Ball.h:73
checkBallCollisions
signed char checkBallCollisions(ball_t *ball, callback_t callback, void *args)
Checks if a ball is currently collided with other objects.
ball::f_x
float f_x
Definition: TUM_Ball.h:72
wall
Object to represent a wall that balls bounce off of.
Definition: TUM_Ball.h:113
ball::dx
float dx
Definition: TUM_Ball.h:75
ball::colour
unsigned int colour
Definition: TUM_Ball.h:81
ball::max_speed
float max_speed
Definition: TUM_Ball.h:78
wall::dampening
float dampening
Definition: TUM_Ball.h:123
ball::args
void * args
Definition: TUM_Ball.h:86
setBallLocation
void setBallLocation(ball_t *ball, signed short x, signed short y)
Sets the location of the ball.
Definition: TUM_Ball.c:119
wall::callback
callback_t callback
Definition: TUM_Ball.h:128
wall::args
void * args
Definition: TUM_Ball.h:129
ball
Object to represent a ball that bounces off walls.
Definition: TUM_Ball.h:68
wall::w
signed short w
Definition: TUM_Ball.h:117
wall::h
signed short h
Definition: TUM_Ball.h:118
ball::radius
signed short radius
Definition: TUM_Ball.h:83
updateBallPosition
void updateBallPosition(ball_t *ball, unsigned int milli_seconds)
Updates the position of the ball.
Definition: TUM_Ball.c:142
wall::colour
unsigned int colour
Definition: TUM_Ball.h:126
createBall
ball_t * createBall(signed short initial_x, signed short initial_y, unsigned int colour, signed short radius, float max_speed, callback_t callback, void *args)
Creates a ball object.
wall::y2
signed short y2
Definition: TUM_Ball.h:121
wall::x2
signed short x2
Definition: TUM_Ball.h:120
createWall
wall_t * createWall(signed short x1, signed short y1, signed short w, signed short h, float dampening, unsigned int colour, callback_t callback, void *args)
Creates a wall object.