O'Reilly logo

Python for Kids by Jason R. Briggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Finishing 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 Ball class, to create a paddle (you’ll stick this in a new line below the Ball draw function):

def ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required