On the main routine, you have a call to a function that detect collisions.
The ball is the only moving object.
What you need to do is checking if the ball "touches" an object or the walls.
Detecting wall hitting is easy: you only need to compare the position of the ball with the border of the window, and invert the xvelocity in case the position is on the wall.
Detecting paddle collision is not that hard: you have an object (a GRect) called "paddle", but wait: you have also bricks that are GRect objects! In both cases, you need to invert the yvelocity of the ball when a collision happen, but if you hit a brick, you need to also delete the brick (a GRect). That hints to an if() statement to detect what object you hit.
So, the final code would be:
- Move the ball
- check for object detection
- if the ball hit the wall, invert xvelocity
- if the ball hit an object, define the type of the object
- if the object is not a paddle, delete the object
- invert yvelocity
That's all, folks :-)
Luigi