• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
ShallWeLearn | shallwelearn.com1
Scratch Programming
Lesson 7: The Pong Game
In this lesson, we will explore a sample game named “Pong”. This game issimple so it's a good place to start learning how to create a game. To openthe “Pong” game, click “Open” and browse to Projects->Games, and thenselect “Pong”. Click OK to open the Pong project.There are two sprites: ball and paddle. The ball sprite moves randomly byits own, whereas the paddle sprite is moved by user moving the mouse.
 
ShallWeLearn | shallwelearn.com2Click the green flag to try the game. Use the paddle to hit the ball as it fallsdown. You should soon find that if the ball hits the bottom of the Stage, thegame would end.
The ball sprite has three comboblocks. You can think of a sprite as a
robot
and each combo block as
aseparate motor
. Just like a robot iscontrolled by many motors, a spritecan be controlled by many comboblocks. In Computer Sciencelanguage, each combo block is
a
thread 
of execution
, workingindependently of the other threads.In the picture shown left, first comboblock controls how the game wouldend - if ball touches red, then gameends.The middle combo block checkswhether the ball has touched thepaddle and takes action when it does.The last combo block checks whetherthe ball has hit the edge and takesaction when it does.
 
ShallWeLearn | shallwelearn.com3The image below shows how a sprite moves in the Scratch stage which isbased on the X-Y coordinate system.This sprite moves according to this script:
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...