First Step VB6 - Keyboard Input

From SwinGame

This is an easy step as we have already added the paddle and all we need to do is tell it to move left and right. This code will of course form part of the Game loop, so find your game loop after the 4 if statements we created previously and add the following code:

If MouseAndKey.IsKeyPressed(Keys_VK_LEFT) Then
    Paddle.setX Paddle.getX - 2 ' move the paddle to the left by 2 pixels
End If

So basically when the user hits the left key it will move the paddle sprite to the left at a rate of 2 pixels per loop, change this number higher if you want it to move faster.

Now you do this...

  • Add the code to make the paddle go right (easy)
  • Add the code to stop the paddle from disappearing off the screen to the right and left. (Think about the X position of the paddle) - Solution

"But the ball just goes through the paddle" I hear you say well that comes next in "Sprite Collisions".