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):