Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed PHP Arrays and Control Structures!
You have completed PHP Arrays and Control Structures!
Preview
In this video, we'll create a simple ping pong game to demonstrate another use case for while loops.
To Win
- player must reach a score of 11
- player must be a minimum of 2 points higher than opponent
WHILE those conditions are NOT met, a single player will receive 1 point at the end of each round.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Let's create a simple ping pong game
to demonstrate another use case for
0:00
while loops.
0:05
Let's create a new file named
pingpong.php We add our PHP tags.
0:06
And then we're ready to
start programming the game.
0:18
We'll start with two players,
each with an initial score of 0.
0:21
$player1 = 0.
0:27
And $player2 = 0.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up