1
00:00:00,180 --> 00:00:05,160
Hey guys, welcome to Day 22 of 100 Days of Code. Today

2
00:00:05,160 --> 00:00:07,170
we're going to be building the famous pong game,

3
00:00:07,770 --> 00:00:11,610
and you're going to be doing this by using all of the skills that you've learned

4
00:00:11,700 --> 00:00:12,533
up till now.

5
00:00:13,440 --> 00:00:16,800
Pong is a classic arcade game,

6
00:00:17,310 --> 00:00:20,040
probably one of the first arcade games that ever was.

7
00:00:20,670 --> 00:00:25,050
And it has a really simple premise. It's basically just a ball

8
00:00:25,050 --> 00:00:29,760
that's going across a table and two players each control a paddle

9
00:00:29,970 --> 00:00:33,240
bouncing the ball back and forth. If you miss the ball,

10
00:00:33,300 --> 00:00:35,010
then the other player scores a point.

11
00:00:36,000 --> 00:00:39,180
Now the history of pong is itself kind of fascinating.

12
00:00:39,570 --> 00:00:43,350
It was created and written by this guy, Allan Alcorn.

13
00:00:43,860 --> 00:00:47,760
And he was a fresh recruit to the Atari company.

14
00:00:48,450 --> 00:00:50,520
And in order to test his skills,

15
00:00:50,550 --> 00:00:53,580
they decided to get him to create a game, from scratch.

16
00:00:54,180 --> 00:00:56,700
And this game happened to be pong,

17
00:00:57,090 --> 00:01:02,090
which became a huge success selling loads and loads of machines across bars and

18
00:01:02,160 --> 00:01:03,060
pubs in the world.

19
00:01:03,600 --> 00:01:08,600
It eventually became so successful that a lot of these bar owners were calling

20
00:01:08,700 --> 00:01:13,110
up Atari saying, Hey, your machines are braking after only a few days.

21
00:01:13,560 --> 00:01:17,790
And the reason when they investigated was because the machines were chock-a-

22
00:01:17,790 --> 00:01:19,740
block full of money.

23
00:01:20,010 --> 00:01:24,690
People were putting their quarters in to play pong and the machine was getting

24
00:01:24,720 --> 00:01:26,100
full too quickly.

25
00:01:26,430 --> 00:01:30,870
So this is the legendary game that we're going to be building today. As a ways,

26
00:01:30,930 --> 00:01:33,390
the first step is to break down the problem.

27
00:01:33,840 --> 00:01:35,640
And I want you to have a go at this,

28
00:01:35,670 --> 00:01:40,140
think about how you would take this pong game that you've seen here,

29
00:01:40,590 --> 00:01:45,480
and which components would we need to write code for, which components might fit

30
00:01:45,480 --> 00:01:47,430
well in its own separate class,

31
00:01:47,760 --> 00:01:52,740
and how might we break down the logic of this game so that we can solve it piece

32
00:01:52,740 --> 00:01:56,910
by piece. Now, I want you to take a piece of paper,

33
00:01:57,000 --> 00:02:02,000
take a look at the game screen right here and make a note of which components

34
00:02:02,310 --> 00:02:06,990
you think could be separated into their own classes. Briefly,

35
00:02:06,990 --> 00:02:11,280
pause the video and jot down some notes on how you might structure the code for

36
00:02:11,280 --> 00:02:12,113
this game.

37
00:02:15,080 --> 00:02:18,860
Now I've broken this tutorial down into eight pieces.

38
00:02:19,340 --> 00:02:22,910
Keep a piece of paper to hand throughout today so that you can compare your

39
00:02:22,910 --> 00:02:24,770
structure to the sample solution.

40
00:02:25,520 --> 00:02:28,430
Pong is a much more complex game than snake.

41
00:02:28,580 --> 00:02:33,050
So pausing to think about the structure of the code now will help you a lot more

42
00:02:33,260 --> 00:02:37,310
in the upcoming lessons and it'll make it easier for you to see how everything

43
00:02:37,310 --> 00:02:41,900
fits together. First, we're going to figure out how to create the screen,

44
00:02:42,230 --> 00:02:46,400
how to create and move a puddle, and then create another puddle

45
00:02:46,400 --> 00:02:50,840
so we can have a two-player game and then create the ball and make it move

46
00:02:50,900 --> 00:02:55,520
constantly across the screen and figure out when it collides with a wall and

47
00:02:55,520 --> 00:03:00,160
make it bounce back and then detect when there's a collision with the paddle to

48
00:03:00,160 --> 00:03:04,510
know when to bounce it back. Finally, we'll figure out when a user scores,

49
00:03:04,780 --> 00:03:09,370
when the paddle misses the ball, and we'll keep the score using a scoreboard

50
00:03:09,400 --> 00:03:13,150
like before. Now, if you're feeling really confident,

51
00:03:13,510 --> 00:03:16,240
you can, in fact, just create a blank project,

52
00:03:16,510 --> 00:03:21,040
go through these steps one by one and see if you can code up this game by

53
00:03:21,040 --> 00:03:23,860
yourself. But what I recommend though

54
00:03:23,890 --> 00:03:28,810
is to go along with the videos and I'm going to explain each of the problems one

55
00:03:28,810 --> 00:03:32,560
by one, and you can have a go at building it alongside with me.

56
00:03:33,070 --> 00:03:35,050
So if you decide to follow along with me,

57
00:03:35,200 --> 00:03:37,630
head over to the next lesson and we'll get started.

58
00:03:38,050 --> 00:03:40,120
If you decide to create everything from scratch,

59
00:03:40,360 --> 00:03:43,510
then pause the video and start creating the game now.

