Hey guys, welcome to Day 22 of 100 Days of Code. Today
we're going to be building the famous pong game,
and you're going to be doing this by using all of the skills that you've learned
up till now.
Pong is a classic arcade game,
probably one of the first arcade games that ever was.
And it has a really simple premise. It's basically just a ball
that's going across a table and two players each control a paddle
bouncing the ball back and forth. If you miss the ball,
then the other player scores a point.
Now the history of pong is itself kind of fascinating.
It was created and written by this guy, Allan Alcorn.
And he was a fresh recruit to the Atari company.
And in order to test his skills,
they decided to get him to create a game, from scratch.
And this game happened to be pong,
which became a huge success selling loads and loads of machines across bars and
pubs in the world.
It eventually became so successful that a lot of these bar owners were calling
up Atari saying, Hey, your machines are braking after only a few days.
And the reason when they investigated was because the machines were chock-a-
block full of money.
People were putting their quarters in to play pong and the machine was getting
full too quickly.
So this is the legendary game that we're going to be building today. As a ways,
the first step is to break down the problem.
And I want you to have a go at this,
think about how you would take this pong game that you've seen here,
and which components would we need to write code for, which components might fit
well in its own separate class,
and how might we break down the logic of this game so that we can solve it piece
by piece. Now, I want you to take a piece of paper,
take a look at the game screen right here and make a note of which components
you think could be separated into their own classes. Briefly,
pause the video and jot down some notes on how you might structure the code for
this game.
Now I've broken this tutorial down into eight pieces.
Keep a piece of paper to hand throughout today so that you can compare your
structure to the sample solution.
Pong is a much more complex game than snake.
So pausing to think about the structure of the code now will help you a lot more
in the upcoming lessons and it'll make it easier for you to see how everything
fits together. First, we're going to figure out how to create the screen,
how to create and move a puddle, and then create another puddle
so we can have a two-player game and then create the ball and make it move
constantly across the screen and figure out when it collides with a wall and
make it bounce back and then detect when there's a collision with the paddle to
know when to bounce it back. Finally, we'll figure out when a user scores,
when the paddle misses the ball, and we'll keep the score using a scoreboard
like before. Now, if you're feeling really confident,
you can, in fact, just create a blank project,
go through these steps one by one and see if you can code up this game by
yourself. But what I recommend though
is to go along with the videos and I'm going to explain each of the problems one
by one, and you can have a go at building it alongside with me.
So if you decide to follow along with me,
head over to the next lesson and we'll get started.
If you decide to create everything from scratch,
then pause the video and start creating the game now.