I am trying to make a well known game (I forget the name) where you control a rectangle 'racket' at the bottom of the screen, move the racket left and right and deflect a ball up the screen to hit and destroy blocks.
Well I'm stuck with how to keep the ball bouncing around the screen:
In the image I have linked to above I've wrote some if statements to dectect when the ball has reached the side of the screen, at which point I plan to call a function to move the ball in it's deflected angle, but :
A matches E, B matches D, C matches G and D matches B.
The only difference is their preceeding states (the direction of the ball before it hits the edge) so I figure I need to use this in combination with the if statement, but I am unsure how.
I considered using a switch statement, but as that only has 1 argument, thought this won't work.
So basically I am looking for some advice on how best to achieve a continusously bouncing ball around the screen.
( I am aware I have not yet addressed balls which hit the corners exactly, ie: 0,0)
If anyone can offer me some advice, I would be most appreciative.