Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

II. Bounce! > 14. Finishing Your First Game: Bounce!

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


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint