1
00:00:00,520 --> 00:00:01,480
Hi, welcome back.

2
00:00:01,660 --> 00:00:05,500
In this video, we will learn how to add school to our game.

3
00:00:05,500 --> 00:00:06,730
Flappy Bird clone.

4
00:00:07,700 --> 00:00:17,090
So we will add a score variable to be called score equals zero as the volume and also add another variable

5
00:00:17,090 --> 00:00:24,150
called high score and assign it to an ensure value equal zero.

6
00:00:25,370 --> 00:00:34,790
So the score and the high school of the Flappy Bird game will start at zero value.

7
00:00:35,150 --> 00:00:45,110
Now we will add techies in our game using pygame, python module and the next three major steps, the

8
00:00:45,110 --> 00:00:49,210
first step to create the font style and size.

9
00:00:49,220 --> 00:00:54,450
So we will determine the style and the size of the game text font.

10
00:00:54,710 --> 00:01:02,580
Then the second step to render font using text and color method of the bi game module.

11
00:01:02,750 --> 00:01:07,930
Finally, we will use the resulting text as a text service.

12
00:01:08,330 --> 00:01:10,700
So font equal pygame.

13
00:01:10,700 --> 00:01:14,000
The font dot font with capital F.

14
00:01:15,330 --> 00:01:25,020
Between two parentheses style and size, font style is a reality free, downloaded font style called

15
00:01:25,470 --> 00:01:31,620
Evil Empire Days for the week between two.

16
00:01:32,570 --> 00:01:44,120
Singer called Coma the size is 50, then we will create a function to display score called display underscore

17
00:01:45,050 --> 00:01:46,880
function as the following.

18
00:01:47,150 --> 00:01:54,710
So yes, this delay underscore this call to empty parentheses of the function, then column.

19
00:01:55,160 --> 00:02:02,390
Then inside the function we will assign a new variable called score underscore sull.

20
00:02:04,890 --> 00:02:05,550
Which.

21
00:02:06,670 --> 00:02:10,090
A shortcut for score underscore.

22
00:02:11,480 --> 00:02:12,080
Service.

23
00:02:13,510 --> 00:02:20,380
Ekwall game and the score from the trender between two parentheses string of score.

24
00:02:21,370 --> 00:02:24,700
And the true and the color of.

25
00:02:25,600 --> 00:02:29,190
The phone, so we will choose the right color.

26
00:02:30,540 --> 00:02:38,220
Which is a table of three values, two hundred fifty five comma, two hundred fifty five comma, two

27
00:02:38,220 --> 00:02:44,120
hundred fifty five, then close to parentheses of the render method.

28
00:02:44,400 --> 00:02:52,740
So we use three parameters in the render method, the first parameter, which is for which we use to

29
00:02:52,740 --> 00:02:57,150
be accepted by the end of the VI game by some module.

30
00:02:57,300 --> 00:03:07,200
And the two refers to actualizing of the phone and the table of three values refers to the white color

31
00:03:07,350 --> 00:03:16,220
of our text or phone text so you can use different values to get different colors for the phone text.

32
00:03:16,290 --> 00:03:24,110
But we will use the white color in this game for the school and to add the surface to the screen.

33
00:03:24,360 --> 00:03:30,780
We will use a rectangle around this as we use and get around there and pi.

34
00:03:31,200 --> 00:03:39,770
And we do that to make it easy to add this font exactly in the middle of our game display.

35
00:03:39,780 --> 00:03:49,890
So score underscore rectangle equal score underscore service dot get underscore recht between two parentheses

36
00:03:50,010 --> 00:03:57,770
center equal a table of two values, one hundred forty three comma and one handwrite.

37
00:03:57,990 --> 00:04:07,710
OK then we can use this font rectangle to end the font tickets to our game, display our game screen

38
00:04:07,740 --> 00:04:08,750
as the following.

39
00:04:09,060 --> 00:04:09,570
So.

40
00:04:11,430 --> 00:04:21,220
Game underscored is the belt between two parentheses score and the score, sir, or service comma is

41
00:04:21,300 --> 00:04:23,280
called Underscore Rectangle.

42
00:04:23,670 --> 00:04:28,590
Finally, we can call that this delay underscore its core function.

43
00:04:30,020 --> 00:04:36,410
Inside our game loop the following, so display underscore.

44
00:04:38,200 --> 00:04:45,750
Two empty parentheses added to the game loop, then buried our project and we get an error.

45
00:04:47,080 --> 00:04:52,510
This error will be solved with the following, we forget to add to F.

46
00:04:53,840 --> 00:05:01,520
Font file extension, so we will add it to correctly load our.

47
00:05:02,420 --> 00:05:12,940
Font file So we get another error and build our product again and we will get another error, this error

48
00:05:13,130 --> 00:05:19,340
day there too, we use game underscore font instead of font.

49
00:05:19,580 --> 00:05:29,630
So we will change that to fund the Trenta, OK, and build our project again and see if it done correctly.

50
00:05:29,630 --> 00:05:38,610
It will run correctly with the score appears on the top of our game display or our game screen.

51
00:05:38,840 --> 00:05:45,690
Now we want to update this zero score to be increased by the player achievement.

52
00:05:46,280 --> 00:05:49,460
Now we will adjust the size of our.

53
00:05:50,560 --> 00:06:01,600
Font as a photo to be 35 instead of 50, then build our project again to see the new size of our phone

54
00:06:01,600 --> 00:06:10,080
ticket and it's OK for the size of our screen, not too big or too small.

55
00:06:10,900 --> 00:06:13,360
Now we will adjust.

56
00:06:14,230 --> 00:06:26,380
The position of this school is the following by using the value of y axis to be to be thirty instead

57
00:06:26,380 --> 00:06:32,370
of one hundred and build our project again to see the evolution of our school.

58
00:06:32,380 --> 00:06:40,870
And it's perfect for our game display and the game screen, as you see.

59
00:06:41,720 --> 00:06:49,540
So we will update the display, underscore its core function as the following users rank four main method

60
00:06:49,540 --> 00:06:53,450
inside the font that render method as the following.

61
00:06:53,620 --> 00:07:04,180
So f single core strength three into parentheses score close the single quote, then comma then true,

62
00:07:04,180 --> 00:07:11,230
then y values inside the table of three items and inside the four main function.

63
00:07:11,230 --> 00:07:23,710
We will add score with capital s column, then string score between two parentheses, then add to curly

64
00:07:24,190 --> 00:07:28,090
brackets and instead of string score as the following.

65
00:07:28,240 --> 00:07:38,620
Then after the second single could not score, this will update always the score inside the string function

66
00:07:38,740 --> 00:07:47,590
or use the second shape of the string for me function to avoid errors when we want to run or build our

67
00:07:47,590 --> 00:07:57,100
Brossette, as you see between single code score with capital s column, then two empty curly brackets.

68
00:07:57,220 --> 00:08:04,840
Not for me, OK, and between two parentheses of the formate function, we add score variable.

69
00:08:05,050 --> 00:08:13,000
Then we build our project, see if we have other errors, and after we build our project, we get another

70
00:08:13,540 --> 00:08:14,260
day or two.

71
00:08:14,290 --> 00:08:24,100
We forget to close the second parentheses of the random, so we will add the second parentheses as the

72
00:08:24,100 --> 00:08:31,300
following and add string score to avoid any errors and run our project again.

73
00:08:31,690 --> 00:08:35,800
And our game runs perfect without any errors.

74
00:08:36,460 --> 00:08:42,910
But we need to increase the score by the achievements of the players.

75
00:08:43,300 --> 00:08:45,460
So let's do that for now.

76
00:08:45,460 --> 00:08:53,710
I will close the game window and we can update the zero score to be increased by the player achievement

77
00:08:53,710 --> 00:09:02,530
in the game loop all the while loop of our code inside the F game underscore on statement we will add

78
00:09:02,530 --> 00:09:11,560
after show by its score plus equal zero point zero one and we will build our project again to run our

79
00:09:11,560 --> 00:09:19,080
game and see if the score updating from zero eight updating partnership of offload value.

80
00:09:19,090 --> 00:09:20,900
So we will change the score.

81
00:09:20,920 --> 00:09:30,340
The last equal entry into parentheses 0.01 and build our project again to see if this problem has been

82
00:09:30,340 --> 00:09:30,960
solved.

83
00:09:31,330 --> 00:09:39,400
And after building the project, we observed that the school is not updating, so we will return the

84
00:09:39,400 --> 00:09:43,450
score value as it was then.

85
00:09:43,630 --> 00:09:46,000
Then change it from the score.

86
00:09:46,000 --> 00:09:54,130
Plus equal 0.01 to score plus equals one and build our project and we see that the score is updating

87
00:09:54,130 --> 00:09:55,120
very quickly.

88
00:09:55,390 --> 00:10:04,960
The question now is how we can updating our score appropriately and adjust this very quick updating

89
00:10:04,960 --> 00:10:05,830
of the score.

90
00:10:06,750 --> 00:10:16,590
We will add and to the four main function inside the font that render method the following, so not

91
00:10:16,590 --> 00:10:20,220
for me between two parentheses string.

92
00:10:21,800 --> 00:10:30,950
Then inside the two branches of the screening function, we will add in between two parents, as is

93
00:10:30,950 --> 00:10:38,380
the school, then returned to the school inside game on the school, on statement to be scored plus

94
00:10:38,450 --> 00:10:48,260
equal or boy or one world out project again to observe our school, which will updating correctly and

95
00:10:48,410 --> 00:10:49,880
effectively for our game.

96
00:10:50,120 --> 00:10:59,840
So everybody the player cross without collusion with the school is updating.

97
00:10:59,960 --> 00:11:07,610
And we observe also that our school needed to be revisited after every collision of the bird with the

98
00:11:07,610 --> 00:11:08,560
game object.

99
00:11:08,570 --> 00:11:19,760
So we can do that and we can do that by adding an a statement inside our display underscore function

100
00:11:19,850 --> 00:11:20,860
as the following.

101
00:11:20,870 --> 00:11:27,350
So inside the function we will end a game on.

102
00:11:28,390 --> 00:11:37,540
To underscore on Columbo, these three lines of code inside the function, to be inside the statement

103
00:11:37,780 --> 00:11:42,230
and add and Elif statement as follows.

104
00:11:42,460 --> 00:11:53,350
So L.F. game on game underscore on the Blackwall Foles column, then Cobbe the three lines inside the

105
00:11:53,350 --> 00:12:01,660
first if statement inside this function, then add these three lines of code inside the ELIF statement

106
00:12:01,960 --> 00:12:11,710
double times the first three lines of code for the score and the second three lines of code or the second

107
00:12:11,710 --> 00:12:13,680
time for the high school.

108
00:12:13,690 --> 00:12:24,670
So we will change all the school and the second time from school to high school as you see it, change

109
00:12:24,670 --> 00:12:36,370
the F game on the on column kento f game equal between two parentheses game underscore on and also ayliffe

110
00:12:36,370 --> 00:12:45,670
game equal game over between two parentheses also and we will head over to the while loop or the game

111
00:12:45,670 --> 00:12:47,800
loop to change something.

112
00:12:47,800 --> 00:12:49,570
Add the following change.

113
00:12:49,570 --> 00:12:58,180
The parameters of the display underscore is called function from empty parameter to between two parentheses.

114
00:12:59,320 --> 00:13:10,360
And between two things, the Colts game on, then Ed and L's statement after this F game on a statement

115
00:13:10,360 --> 00:13:17,410
as the volume so else this play underscore its core function between two parentheses and two single

116
00:13:17,410 --> 00:13:19,990
quotes game underscore over.

117
00:13:20,020 --> 00:13:28,720
So if the game is on, the display is called function will display the school and else game is over.

118
00:13:28,870 --> 00:13:31,690
The display on the school function well.

119
00:13:31,690 --> 00:13:34,540
Display the score and the high school.

120
00:13:34,780 --> 00:13:43,090
Now we need to adjust the possession of our high school as a follow and we will change it from 30 to

121
00:13:43,090 --> 00:13:47,050
one hundred and build our project again.

122
00:13:49,160 --> 00:13:51,050
And we get an air of.

123
00:13:52,950 --> 00:14:02,580
Due to missing column of the F statement F game with equal between two parentheses game on, we add

124
00:14:02,580 --> 00:14:10,050
the missing column, then build our project again and we get another error, which is due to missing

125
00:14:10,050 --> 00:14:13,530
parameters, and that is delay, underscore function.

126
00:14:14,040 --> 00:14:16,940
We have a type error, which is this.

127
00:14:16,950 --> 00:14:22,950
Bedier underscore function takes zero positional arguments, but we add.

128
00:14:23,790 --> 00:14:30,930
One argument or one parameter inside the method of the function, so we will return to the function

129
00:14:31,080 --> 00:14:39,570
and add this parameter as the volume, so the function parameter or argument will be the gain and build

130
00:14:39,570 --> 00:14:40,700
our project again.

131
00:14:41,220 --> 00:14:44,420
It run correctly without any errors.

132
00:14:44,610 --> 00:14:48,560
And also we get that set of the scope, as you see.

133
00:14:48,570 --> 00:14:52,740
But the high score is not found at the game over screen.

134
00:14:52,860 --> 00:15:00,050
As you see, we can solve this problem by adding a new function called high score update function.

135
00:15:00,600 --> 00:15:11,250
So Def High, underscore the score, underscore the between two parentheses the score comma high score

136
00:15:11,370 --> 00:15:12,390
then column.

137
00:15:12,660 --> 00:15:17,970
Then inside this function we will add in every statement as the following.

138
00:15:18,210 --> 00:15:28,470
So if it's more than high, underscore the score goal, then high on those core score equals score.

139
00:15:29,380 --> 00:15:39,460
Then return high, underscore school, then inside the game loop all the while loop, we will call this

140
00:15:39,460 --> 00:15:48,520
function high school update or else column before the display underscore the school method.

141
00:15:48,760 --> 00:16:01,210
We will add high underscore equal high school update function between two parentheses school and the

142
00:16:01,210 --> 00:16:02,090
high school.

143
00:16:02,290 --> 00:16:11,170
We will head to the high school service and the change the school to high school and the for me and

144
00:16:11,170 --> 00:16:16,600
re-enter function so high on the school school.

145
00:16:16,720 --> 00:16:23,170
Underscore of a call from the trender between two parentheses and two single quotes.

146
00:16:23,170 --> 00:16:31,650
High school inside the four main function instead of school and inside the game underscore display the

147
00:16:31,670 --> 00:16:32,950
belet method.

148
00:16:34,000 --> 00:16:39,070
We will add high, underscore the school and the school service and.

149
00:16:40,000 --> 00:16:49,660
High school rectangle instead of a school rectangle, then we will build our project again and our game

150
00:16:49,660 --> 00:16:53,750
runs perfectly, but the score is the same as the high school.

151
00:16:53,890 --> 00:17:02,000
So we want to reset the score every time we play the game and the game over the screen or background.

152
00:17:02,020 --> 00:17:11,800
So we will head over the statement in the while loop or the game loop then and the score equal zeal

153
00:17:11,830 --> 00:17:17,100
to reset the score at the game over screen or background.

154
00:17:17,380 --> 00:17:24,070
So and we will our goes back again to see if this error have been solved or not.

155
00:17:25,930 --> 00:17:36,280
And we observe that there have been solved and everything is OK and the school and high school are perfectly

156
00:17:36,280 --> 00:17:42,430
showing on the game over screen at this point, we reached the end of this lecture.

157
00:17:42,620 --> 00:17:45,190
I hope you enjoyed this lecture and get all of that.

158
00:17:45,390 --> 00:17:48,340
Thanks for watching and thanks for being here.

159
00:17:48,640 --> 00:17:50,530
See you next with you.
