2️⃣

Instructions

 
 
  1. Create game display
      • Create and title project
      • Choose background
      • Delete cat sprite
  1. Create two paddles
      • Create and name sprites
      • Resize sprites
      • Place sprites on screen (one paddle to the left, and one to the right)
      • Create a game loop for the paddles
      • Create a velocity variable (only for y coordinate)
      • Create an isDown variable (this variable will check if any keys are pressed down)
      • Set value of velocity variable based on keyboard input
        • Example: If ‘W’, change velocity by 10
        • Example: If ‘S’, change velocity by -10
      • Change the y value based on the value of the velocity variable
  1. Create and display two points tables on the screen
      • Set the initial score of each points table to 0
      • Increase the number of points a player gets by 1 every time the ball hits the wall on the opposing player’s side
      • The game ends as soon as one player has 21 points
  1. Create ball element
      • Create and name object
      • Resize object
      • Create a game loop for the ball
      • Set initial position of the ball to the center of the game display
      • Create variables called xVelocity and yVelocity
      • The game starts when the ball starts moving - the ball should start moving when the spacebar is pressed
      • If the ball hits the top of the game display, multiply the value of yVelocity by -1
      • If the ball hits either paddle, multiply the value of xVelocity by -1
      • Change the position of the x value of the ball by the value of xVelocity
      • Change the position of the y value of the ball by the value of yVelocity
  1. Create clear game instructions to be displayed at the beginning of the game
      • Explain the objective of the game
      • Explain how to play the game
  1. Create display for the end of the game
      • Display the words “Game Over”
      • Display each of the users’ total points
      • Prompt them to play again

Previous Section

1️⃣
Intro to Pong
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.