WEBVTT

0
00:00.180 --> 00:05.160
Hey guys, welcome to Day 22 of 100 Days of Code. Today

1
00:05.160 --> 00:07.170
we're going to be building the famous pong game,

2
00:07.770 --> 00:11.610
and you're going to be doing this by using all of the skills that you've learned

3
00:11.700 --> 00:12.533
up till now.

4
00:13.440 --> 00:16.800
Pong is a classic arcade game,

5
00:17.310 --> 00:20.040
probably one of the first arcade games that ever was.

6
00:20.670 --> 00:25.050
And it has a really simple premise. It's basically just a ball

7
00:25.050 --> 00:29.760
that's going across a table and two players each control a paddle

8
00:29.970 --> 00:33.240
bouncing the ball back and forth. If you miss the ball,

9
00:33.300 --> 00:35.010
then the other player scores a point.

10
00:36.000 --> 00:39.180
Now the history of pong is itself kind of fascinating.

11
00:39.570 --> 00:43.350
It was created and written by this guy, Allan Alcorn.

12
00:43.860 --> 00:47.760
And he was a fresh recruit to the Atari company.

13
00:48.450 --> 00:50.520
And in order to test his skills,

14
00:50.550 --> 00:53.580
they decided to get him to create a game, from scratch.

15
00:54.180 --> 00:56.700
And this game happened to be pong,

16
00:57.090 --> 01:02.090
which became a huge success selling loads and loads of machines across bars and

17
01:02.160 --> 01:03.060
pubs in the world.

18
01:03.600 --> 01:08.600
It eventually became so successful that a lot of these bar owners were calling

19
01:08.700 --> 01:13.110
up Atari saying, Hey, your machines are braking after only a few days.

20
01:13.560 --> 01:17.790
And the reason when they investigated was because the machines were chock-a-

21
01:17.790 --> 01:19.740
block full of money.

22
01:20.010 --> 01:24.690
People were putting their quarters in to play pong and the machine was getting

23
01:24.720 --> 01:26.100
full too quickly.

24
01:26.430 --> 01:30.870
So this is the legendary game that we're going to be building today. As a ways,

25
01:30.930 --> 01:33.390
the first step is to break down the problem.

26
01:33.840 --> 01:35.640
And I want you to have a go at this,

27
01:35.670 --> 01:40.140
think about how you would take this pong game that you've seen here,

28
01:40.590 --> 01:45.480
and which components would we need to write code for, which components might fit

29
01:45.480 --> 01:47.430
well in its own separate class,

30
01:47.760 --> 01:52.740
and how might we break down the logic of this game so that we can solve it piece

31
01:52.740 --> 01:56.910
by piece. Now, I want you to take a piece of paper,

32
01:57.000 --> 02:02.000
take a look at the game screen right here and make a note of which components

33
02:02.310 --> 02:06.990
you think could be separated into their own classes. Briefly,

34
02:06.990 --> 02:11.280
pause the video and jot down some notes on how you might structure the code for

35
02:11.280 --> 02:12.113
this game.

36
02:15.080 --> 02:18.860
Now I've broken this tutorial down into eight pieces.

37
02:19.340 --> 02:22.910
Keep a piece of paper to hand throughout today so that you can compare your

38
02:22.910 --> 02:24.770
structure to the sample solution.

39
02:25.520 --> 02:28.430
Pong is a much more complex game than snake.

40
02:28.580 --> 02:33.050
So pausing to think about the structure of the code now will help you a lot more

41
02:33.260 --> 02:37.310
in the upcoming lessons and it'll make it easier for you to see how everything

42
02:37.310 --> 02:41.900
fits together. First, we're going to figure out how to create the screen,

43
02:42.230 --> 02:46.400
how to create and move a puddle, and then create another puddle

44
02:46.400 --> 02:50.840
so we can have a two-player game and then create the ball and make it move

45
02:50.900 --> 02:55.520
constantly across the screen and figure out when it collides with a wall and

46
02:55.520 --> 03:00.160
make it bounce back and then detect when there's a collision with the paddle to

47
03:00.160 --> 03:04.510
know when to bounce it back. Finally, we'll figure out when a user scores,

48
03:04.780 --> 03:09.370
when the paddle misses the ball, and we'll keep the score using a scoreboard

49
03:09.400 --> 03:13.150
like before. Now, if you're feeling really confident,

50
03:13.510 --> 03:16.240
you can, in fact, just create a blank project,

51
03:16.510 --> 03:21.040
go through these steps one by one and see if you can code up this game by

52
03:21.040 --> 03:23.860
yourself. But what I recommend though

53
03:23.890 --> 03:28.810
is to go along with the videos and I'm going to explain each of the problems one

54
03:28.810 --> 03:32.560
by one, and you can have a go at building it alongside with me.

55
03:33.070 --> 03:35.050
So if you decide to follow along with me,

56
03:35.200 --> 03:37.630
head over to the next lesson and we'll get started.

57
03:38.050 --> 03:40.120
If you decide to create everything from scratch,

58
03:40.360 --> 03:43.510
then pause the video and start creating the game now.