Creating a Pong 2 Player Game: Mr. Veronsky, Grade 7, Computer Applications

OBJECTIVE: Students will learn about: creating background, creating objects, object oriented programming.

Class Activities:

Open a web browser and navigate to the Scratch website: http://scratch.mit.edu

Sign in using your ID which is your first initial followed by your last name and your password which is your student ID.

Create a Paddle Sprite and Label it as “Player 1”

  1. Click “Paint new sprite” icon
  2. Draw a rectangle with the rectangle tool
  3. Fill the rectangle with color
  4. Name the sprite “Player 1” by right clicking on the sprite box on the bottom and click on info, then name the object “Paddle”
  5. For your code, we want to use the “q” and “a” keys to move the paddle, you will need 2 scripts, one to move 10 steps along the “Y” axis when the “q” letter is pressed and one to move -10 steps along the “Y” axis when the “a” letter is pressed

Create a second Paddle Sprite and Label it as “Player 2”

1.  Right click on your “Player 1” sprite and duplicate it, then name it “Player 2”

2.  You will want to modify your code, we want to use the “up arrow” and “down arrow” keys to move the paddle, you will need 2 scripts, one to move 10 steps along the “Y” axis when the “up arrow” letter is pressed and one to move -10 steps along the “Y” axis when the “down arrow” letter is pressed

Create a ball sprite

  1. Click “choose new sprite” icon
  2. Double click the ball
  3. We need a script that starts the game, then starts the ball at a specific location, say x(20) and y(150), then get it moving at a 45 degree angle. The ball will need a loop that will bounce it forever if it hits a side, then moves 10 steps
  4. Let’s add a couple of variables called “Player 1” and “Player 2” to keep track of how many times the ball hits a players paddle.
  5. We need a second script that starts when the game starts, this script will determine if the ball hits the paddle for player 1 and then redirects it. Once again we will need a loop that will determine if the ball is touching the paddle, then turn the ball in the opposite direction and randomly move the ball in another direction, then move 10 steps. Don’t forget to add a point to the player 1 variable.
  6. We need a third script that starts when the game starts, this script will determine if the ball hits the paddle for player 2 and then redirects it. Once again we will need a loop that will determine if the ball is touching the paddle, then turn the ball in the opposite direction and randomly move the ball in another direction, then move 10 steps. Don’t forget to add a point to the player 2 variable.
  7. Make sure to initialize both variables in the script for step 3 to zero.

Add a background of a wall to enhance the visual appeal of the game.

Rubric:

Criteria / Excellent (20) / Fair (10) / Needs Improvement (5)
Paddle1 / Correct shape and filled with color, contains 2 scripts that move the paddle up and down when the q and a keys are depressed / Scripts are not functioning correctly or paddle was not created properly / missing
Paddle2 / Correct shape and filled with color, contains 2 scripts that move the paddle up and down when the up and down keys are depressed / Scripts are not functioning correctly or paddle was not created properly / missing
Ball / Contains 2 scripts, one that moves the ball and another that redirects the ball when it hits the paddle / Scripts are not functioning correctly / missing
Background / Correctly inserted / missing
Variables / Properly initialized and incremented properly / Scripts are not functioning correctly / missing