Session 8: We play one against one

Work plan

  • We add players
  • We limit the playing field

Two players

So far we have programmed a solo game against the ball. Let’s see how we can do to play more players at the same time.

Step by step Let’s do it step by step

  • Entering our Scratch account, we open the m2repte71 project and set it as m2repte81
  • In order for two players to take, for example, the original Pong made by Atari in 1972:
    Atari 1972
  • We need two rackets, and they are vertical. So, we turn 90 degrees the racket that we currently have and we double it to have two. We put one on each side of the field. Remember to place the center of the dress wherever you touch
  • Each of the rackets must be moved independently. We can maintain that the racquet on the right is moved with the arrow keys on the keyboard, while the left racket can be moved, for example, with the “W” (up) and “S” keys (to go down )
  • We need two lines of death. Therefore, we modify the line of death that we have right now, we duplicate it and put one in each side of the field, just by touching the edge
  • We need two variables to count each player’s points separately. We create the variables “player 1” and “player 2”
  • We consider that the player on the left is “player 1” and adds a point when the ball touches the line of death from the right. Consequently, the player on the right is “player 2” and will add a point when the ball touches the line of the left’s death
  • Our screen of the Pong should stay more or less like this:
    Pong two players
  • We need to modify the logic of the program by replacing the variable “points” for the two new variables we have created. These two variables have to be initialized to zero at the beginning of the program and we have to do that they are increased when the ball touches the line of the opposite death
  • The end of game condition must also be changed so that the game ends when one of the players reaches, for example, at 15 points
  • We can also maintain the increase of the difficulty so that when a player arrives at 5 or 10 points his racket is made a little smaller

Icon challenge Challenge 1:

Let’s make a copy of the m2repte81 project and set it as m2repte82. We modify it so that four players can play as if it were a tennis match, where there are two more advanced players and two more behind them:
Pong four tennis players


Icon challenge Challenge 2:

Let’s make a copy of the m2repte81 project and set it as m2repte83. We modify it so that four players can play cooperatively where the objective is to make the maximum number of racket hits between all four without touching any edge:
Pong four cooperative players

Icon track Track: Since the goal is not to touch any edge, the game we can do with lines of death or controlling the contact with the edges:
Touching edge


Icon project Our project grows …

Our pinball project  will also have to take into account two players, since we will have to position both sides of the output hole two blades to prevent the ball from falling too fast and to push it up again. We must add this fact to the description that we are developing.


Glossary icon Because we are programmers and programmers we talk about …

  • Controls: defined keys to interact on the game by directing some characters.