Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Gaming - Second Edition

You're reading from   Raspberry Pi Gaming - Second Edition Design, create, and play all kinds of video games on your Raspberry Pi computer

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher
ISBN-13 9781784399337
Length 140 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Shea Silverman Shea Silverman
Author Profile Icon Shea Silverman
Shea Silverman
Arrow right icon
View More author details
Toc

Ping Pong

It's time to go back in time, and recreate a game that helped to launch the video game industry. It has gone by many names such as Pong, Ping Pong, and Table Tennis, but the basic gameplay has stayed the same. Two paddles, one ball, and an epic battle to get the ball past the other player.

So, let's break down this game. We will require:

  • One paddle for the left player
  • One paddle for the right player
  • One bouncing ball
  • Two variables to keep score for each player.

Let's get started!

Making the paddles

After creating a new project, you will be presented with the white stage and a Scratchy sprite.

  1. Right-click on Scratchy and click on delete. Now, click on Paint new sprite.
    Making the paddles
  2. Draw a long black rectangle and click on OK. Name this sprite Left.

    We are going to create three simple scripts for this paddle, as follows:

    Making the paddles
  3. The first script ensures that the left paddle points in the proper direction and then sets its size to 60 percent. You should experiment with the size to determine what feels...
You have been reading a chapter from
Raspberry Pi Gaming - Second Edition - Second Edition
Published in: Feb 2015
Publisher:
ISBN-13: 9781784399337
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image