Collision Response Tweaking
What I did not expect was for this process to take the time it did. Surprisingly the most difficult thing about breakout is calculating a predictable response from the ball hitting something. For the boundaries around the game area, I simply reverse the X or Y direction depending on which wall was it. For the paddle or the bricks it’s not so simple.
Part of the expected functionality is to have the distance off the center of a brick or paddle affect the rebound effect. To make it even harder, velocity of the paddle also affects this. Fortunately, yet another expectation is that horizontal speed should never exceed vertical speed, making collision response a little more manageable.
What I initially worked out as correct calculations turned out to be misleading me, as I forgot that I centered the position of objects rather than using the top-left position during my little calculator session. Fortunately I got that working. My testing environment strangely enough was the menu rather than the actual game area, as my menu will consist of a paddle hitting the ball around the screen. What also didn’t help was the fact the normalisation function that came with a sub-set of SFML’s library didn’t work, although manual calculation of this fixed this quite quickly.
Now that is sorted, I should be able to add bricks in with simple for loops and increment a score. Although the difficulty curve is now beyond the peak for this project, it makes me somewhat nervous for the recreation of Pac-man, with AI and path-finding which I have had very little experience with, regardless of having planes, boats and soldiers roaming around an island in a 3D environment. At least I don’t have to worry about calculating the direction of Pac-man bouncing off walls.
After 2 days of work I have a paddle and a ball on the screen which isn’t particularly impressive, although this was mainly due to mathematical confusion that took place. The structure of all important entities are done so far except for elements such as menu systems and a highscore system. File handling isn’t exactly new to me, although doing things without the aid of external physics or GUI libraries I’m exploring things from a whole new perspective.