image

14FINISHING YOUR FIRST GAME: BOUNCE!

In the previous chapter, we got started creating our first game: Bounce! We created a canvas and added a bouncing ball to our game code. But our ball will bounce around the screen forever (or at least until you turn your computer off), which doesn’t make for much of a game. Now we’ll add a paddle for the player to use. We’ll also add an element of chance to the game, which will make it a bit more challenging and fun to play.

ADDING THE PADDLE

There’s not much fun to be had with a bouncing ball when there’s nothing to hit it with. Time to create a paddle!

Begin by adding the following code just after the

Get Python for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.