First Step VB.NET - Sprite Collisions

Although it is fun watching a ball bounce aimlessly around the screen it would be nice if we could interact with it. To do this we need to tell our program to look out for a collision. Namely a collision between the ball and the paddle. If this collision occurs then obviously we need to tell the program to bounce the ball off in the other direction the same as if we had hit the bottom or top by reversing the Y axis of the path of the ball.

The code to test if there is a collision between the two sprites is: Add this to your game loop.

Now you do this...

 * Make the "paddlehit" sound play when there is a collision between the ball and the paddle (easy)
 * Add a second paddle to the game so you can play against a friend in a pong style game. You will need to follow the same process you did for the first paddle.
 * Download the [[Media:RedPaddle.png|RedPaddle]] [[Image:RedPaddle.png|30 px]]
 * Add the new image to Gameresources.vb in the code
 * Now back to GameLogic.vb to declare (dim) the new Sprite also set position (x and y) of red paddle and set the buttons to make the paddle move (perhaps z and x)
 * In Game Loop draw the red paddle and set up the collision, stop it being able to move off the screen. Then test it out against a friend.
 * Figure out how to add Scoring to your game

Advanced Sprite Collisions
As you play the game for a while you will notice something is not right with what happens when the ball hits the side of the paddle. It seems to get stuck to the paddle, work its way across and then get free. This is to do with the fact that the game does not understand side collisions. In order to make it understand this we need to add the following code to GameLogic.vb just underneath the very first line which is "Module GameLogic":

then change the collision code down in your game loop to the following(oh and don't forget to add the line for the "paddlehit" sound to this as well):

Next let's get a Scoring feature for our game so you can keep track with who is winning.