Vector based movement

Tonight I converted ball movement from being based on X & Y change values (which were added to the ball position each time through the game loop) to being vector based. A bit more math, but it’s much more flexible.

Once I had that working, I added a velocity vector to the paddle to reflect it’s movement. This vector had a magnitude of 0.25 when the paddle was moving and 0 when it was still. The angle was 0 or PI, when the paddle was moving right or left, respectively.

Then I had the paddle collision handling add the paddle velocity to the ball’s velocty vector. This gives the abiity to slice the ball when returning.. letting the player manipulate the speed and angle of the ball.

These fairly small changes really improve the feel of the game.

Leave a Reply

You must be logged in to post a comment.