1
00:00:00,420 --> 00:00:01,850
Hi, welcome back.

2
00:00:01,870 --> 00:00:10,310
In this lecture, we will complete our game and adding a bouncing poll arcade game like Pong Game are

3
00:00:10,320 --> 00:00:20,700
based on a frame based animation where the screen is refreshed every specific milliseconds and moving

4
00:00:20,710 --> 00:00:27,240
sprites are doing by using X and Y coordinates or axis.

5
00:00:27,870 --> 00:00:38,400
And they have a variety vector V, X and VI, which is specified the Delta and vectors to apply to X

6
00:00:38,400 --> 00:00:45,140
and Y coordinates or position or axis of as between two friends.

7
00:00:46,140 --> 00:00:54,360
So to move the Sprite across the game, display or screen, it will need to bounce against a Sprite

8
00:00:54,360 --> 00:00:58,640
or against the edge of the screen or the game play.

9
00:00:59,460 --> 00:01:06,400
So we will copy the code and the battle module and it in a new file.

10
00:01:07,980 --> 00:01:19,830
And name it as bull, but by then it that last name from bottle to glass bowl with the capital and we

11
00:01:19,830 --> 00:01:24,720
will add after the line of code that draws correct.

12
00:01:24,870 --> 00:01:25,670
Mesud.

13
00:01:26,710 --> 00:01:30,430
Self-taught velocity equals.

14
00:01:33,590 --> 00:01:41,060
A list of rendang between two parenthesis rendang, four and eight, and Ron it.

15
00:01:42,750 --> 00:01:51,870
Minus eight and a close saw, self-taught, wealthy, when Ekwall, a list of two ran, then it off

16
00:01:51,870 --> 00:02:04,500
to table four and eight or minus eight and a so Zahran then, which is part of a random module, will

17
00:02:05,070 --> 00:02:18,180
it chose between four and a four varity Hendrick's zero or minus eight and a four velvety index one.

18
00:02:18,190 --> 00:02:26,450
So we will add this in bold statement from random and bold rond in it.

19
00:02:27,090 --> 00:02:32,370
Now we will add a function that will upgrade the ball.

20
00:02:32,940 --> 00:02:40,880
Velocity has the following and it will take one parameter which is self.

21
00:02:40,890 --> 00:02:46,020
So def update between two parentheses self column.

22
00:02:47,390 --> 00:02:52,520
And inside this function, we will add self-doubt, recht dot x.

23
00:02:53,450 --> 00:02:58,850
Plus, equal self-doubt, first index zero.

24
00:03:00,990 --> 00:03:12,540
And for the movement or the validity of the bowl ads, the X, Y or the Y position will be as the following

25
00:03:12,540 --> 00:03:25,290
self-taught Recht not Y plus equal self-doubt versity between two square brackets, one and X number

26
00:03:25,290 --> 00:03:26,570
one, OK.

27
00:03:28,440 --> 00:03:37,380
Finally, we want to add a function to Zabol class that will make our ball bounce.

28
00:03:38,220 --> 00:03:48,900
And we'll take also self as the only parameter, so Jeff Ball underscored bouncing between two parentheses

29
00:03:48,900 --> 00:03:55,780
self column and inside this function we will add self-doubt.

30
00:03:56,220 --> 00:04:02,430
Where's the index number zero equal minus self see?

31
00:04:03,400 --> 00:04:07,420
And zero and self-taught versity.

32
00:04:08,610 --> 00:04:14,400
Between two square brackets, one equal self-doubt versity.

33
00:04:16,170 --> 00:04:25,470
And that's number one, then we will add the ball to the game that by five and the following using the

34
00:04:25,470 --> 00:04:35,600
object of class, so we will import the class pool as a falling from pole balls ball with B capital.

35
00:04:35,790 --> 00:04:46,110
Then we will add the ball to the ball boy as a foul ball will equal the ball class opposite ball ekwall

36
00:04:46,350 --> 00:04:53,280
ball with capital B between two parentheses Y and Tony and Tony.

37
00:04:54,540 --> 00:05:03,780
This will be the colour and width and the height of the ball rectangle, so ball, dot, dot, x equals

38
00:05:03,960 --> 00:05:09,780
four hundred and ball the dot Y equals two hundred.

39
00:05:09,990 --> 00:05:15,560
Now we will add the sprite of our ball and the following.

40
00:05:15,840 --> 00:05:22,140
So sprites underscored last dot at between two parentheses ball.

41
00:05:22,320 --> 00:05:31,010
Now we will add the ball bouncing algorithm which will control the two methods of the ball class.

42
00:05:31,020 --> 00:05:40,590
But first we will add an after statement which contain event type or another, even the type.

43
00:05:41,660 --> 00:05:52,970
Has the following F even type equal by game dot K down column and inside this F statement, we will

44
00:05:52,970 --> 00:06:03,710
add another nested F statement as the following f even Doti will equal by game the K capital under score

45
00:06:04,040 --> 00:06:05,600
x small column.

46
00:06:05,610 --> 00:06:11,270
So game underscore on equal falls.

47
00:06:11,870 --> 00:06:21,080
Now we can add the ball bouncing algorithm at the following after as bright as update method f statement

48
00:06:21,080 --> 00:06:32,900
ball dot dot x more than or equal seven hundred add column for ball dot t of index zero equal minus

49
00:06:32,910 --> 00:06:33,500
ball.

50
00:06:34,620 --> 00:06:35,970
That was the.

51
00:06:37,490 --> 00:06:39,260
Of Index zero.

52
00:06:40,140 --> 00:06:43,230
So Zabol that wrecked that X.

53
00:06:44,400 --> 00:06:47,400
If equal or more than seven.

54
00:06:48,620 --> 00:06:50,540
Hundred and eighty bexell.

55
00:06:52,090 --> 00:06:57,850
The validity of index zero will equal mine as well as the.

56
00:06:59,070 --> 00:07:09,150
Of Index zero, Zabol will move in another or the opposite position and we will return the X and Y position

57
00:07:09,150 --> 00:07:19,820
of the ball as the following Zabol Lautrec but to be equal 400 and the ball to attract the Y to be two

58
00:07:19,890 --> 00:07:20,430
hundred.

59
00:07:24,610 --> 00:07:32,230
Zabol will return to the position that it was in at the beginning of the game.

60
00:07:36,020 --> 00:07:39,760
And we will copy this statement for time.

61
00:07:40,250 --> 00:07:40,760
OK?

62
00:07:43,410 --> 00:07:53,730
But we change in the second time that the ball got wrecked, that X less than or equal to then add the

63
00:07:53,730 --> 00:08:00,810
column and we will let the rest of the F statement as it is.

64
00:08:01,920 --> 00:08:13,650
Then adding that's her statement as the following involved dot, red dot, why more than five hundred

65
00:08:13,650 --> 00:08:17,700
and eighty so self dot Melasti.

66
00:08:19,050 --> 00:08:23,370
But in here, we will change the index to be.

67
00:08:24,570 --> 00:08:24,990
One.

68
00:08:28,880 --> 00:08:30,950
Then we will add.

69
00:08:32,770 --> 00:08:41,560
Another statement, which is a false statement, if both dot dot, why more than not more than less

70
00:08:41,560 --> 00:08:43,750
than zero collomb.

71
00:08:44,140 --> 00:08:51,700
So the dot was the one equal minus the the one.

72
00:08:53,080 --> 00:08:55,870
And we can change zero to be do.

73
00:09:00,050 --> 00:09:02,450
And check the identity of our good.

74
00:09:04,680 --> 00:09:16,110
And add the fifth statement as a following, if I gave that Sprite Dot Cleide underscore must.

75
00:09:16,990 --> 00:09:26,450
Missile and inside this missile, we will add two parameters, which are bold, bright and better.

76
00:09:26,520 --> 00:09:27,470
One is bright.

77
00:09:29,460 --> 00:09:29,970
Or.

78
00:09:31,400 --> 00:09:35,570
By game dot dot Cleide underscore mask.

79
00:09:36,350 --> 00:09:38,690
Ball and puggle to.

80
00:09:39,920 --> 00:09:41,390
And at Collomb.

81
00:09:43,440 --> 00:09:46,980
Then inside the statement, we will add.

82
00:09:47,810 --> 00:09:49,730
Ball bouncing.

83
00:09:51,350 --> 00:09:53,960
Method which exist inside.

84
00:09:55,180 --> 00:09:56,900
Zable class.

85
00:09:58,290 --> 00:10:00,750
Hold the ball, goodbye.

86
00:10:02,090 --> 00:10:02,540
Five.

87
00:10:04,490 --> 00:10:05,180
As you see.

88
00:10:06,590 --> 00:10:09,890
Now we can build out Rosie to check.

89
00:10:10,850 --> 00:10:14,330
If our game run correctly or not.

90
00:10:15,010 --> 00:10:17,830
So let's build our Rosie.

91
00:10:22,610 --> 00:10:26,120
After building our music, we have an air of.

92
00:10:27,110 --> 00:10:27,920
As you see.

93
00:10:28,850 --> 00:10:30,970
So we will.

94
00:10:32,050 --> 00:10:34,210
Solve this error the following.

95
00:10:34,780 --> 00:10:40,770
The error due to adding self parameter outside the ball.

96
00:10:42,020 --> 00:10:44,270
That by five or Polglase.

97
00:10:45,300 --> 00:10:47,700
So we will add more.

98
00:10:49,050 --> 00:10:57,540
And instead of self so bold that wealthy, not self, not wealthy, we will change all.

99
00:10:58,630 --> 00:11:00,010
They're mistaken.

100
00:11:01,340 --> 00:11:08,690
Or the ad by mistake self-doubt fallacy and change it to Paul Valency.

101
00:11:09,910 --> 00:11:12,460
And run our project again.

102
00:11:16,120 --> 00:11:24,910
We will get another error that we have no attributes of pygame called gay.

103
00:11:26,430 --> 00:11:27,960
Underscore X.

104
00:11:28,980 --> 00:11:40,200
So we will it sends even the time to even dot gay, which contain by game dot gay, underscore X and

105
00:11:40,200 --> 00:11:43,290
run our project again and we get another Aros.

106
00:11:44,340 --> 00:11:57,000
Which as we at gays small, which is incorrect by game dot k capital, underscore X small and run out

107
00:11:57,390 --> 00:12:05,820
again and get other errors, which is an error in moving up and moving down methods of the battles.

108
00:12:06,000 --> 00:12:09,510
So we will head over the battle.

109
00:12:11,080 --> 00:12:17,290
Goodbye file to check this error, which is due to.

110
00:12:19,210 --> 00:12:20,440
Number of bexell.

111
00:12:21,720 --> 00:12:24,300
I'm not.

112
00:12:25,830 --> 00:12:32,280
Assigned to the the threat we by mistake or.

113
00:12:33,670 --> 00:12:34,990
Commit an error.

114
00:12:35,980 --> 00:12:37,510
By adding Bexell.

115
00:12:38,700 --> 00:12:45,750
And instead of number of pics, so we will change it to number of pixels.

116
00:12:48,770 --> 00:12:54,050
And go to bonke dot, buy and build our product again, it will run.

117
00:12:58,880 --> 00:13:05,270
Without re importing the Zabol, so this.

118
00:13:07,090 --> 00:13:18,130
This error is due to we add the position of the ball that wrecked X due time without remembering to

119
00:13:18,130 --> 00:13:26,410
add X and Y, so we will add X and Y and the ball, the track position.

120
00:13:27,350 --> 00:13:32,670
To be X equals four hundred and Y equal two hundred.

121
00:13:33,070 --> 00:13:40,450
Also, we will change the speed of the game or the speed of the ball to be six instead of seven.

122
00:13:41,260 --> 00:13:45,150
But we have another mistake or error.

123
00:13:46,000 --> 00:13:46,990
That's all.

124
00:13:48,530 --> 00:13:49,160
Only.

125
00:13:50,080 --> 00:13:54,370
Balance and one direction without.

126
00:13:55,540 --> 00:14:06,640
Making another angle of the reverse direction, this will be solved and the following year will change

127
00:14:06,640 --> 00:14:15,830
the weight of the middle line, then we will change the method of bouncing self-support velocity of

128
00:14:15,830 --> 00:14:22,980
an X one equal self-taught velocity and X one and build our Brusic to get the following rhythm.

129
00:14:23,440 --> 00:14:31,570
And also, will it change the update method as the following to be said would attract dot y plus equals

130
00:14:31,570 --> 00:14:36,010
self-taught, wealthy and x1 and run our project again.

131
00:14:39,330 --> 00:14:49,100
And our game will run fine without any errors and with the ball, the correct ball movement.

132
00:14:49,800 --> 00:14:59,400
And the correct ball bouncing algorithm, as you see, and we need to change some numbers and battle

133
00:14:59,400 --> 00:15:01,930
Dobi and the weather moving down massive.

134
00:15:01,980 --> 00:15:07,080
So self the track that way, more than four hundred seventy five column.

135
00:15:07,410 --> 00:15:14,820
And inside the statement itself, dot, dot y equals four hundred seventy five and bailed out again

136
00:15:14,940 --> 00:15:21,170
to run our game and it will run correctly without any error.

137
00:15:21,480 --> 00:15:25,520
And with the correct ball movement and bouncing.

138
00:15:26,700 --> 00:15:32,700
We can also change these numbers to four hundred and sixty which more appropriate.

139
00:15:32,710 --> 00:15:40,650
And we will check that by building our project again as the following to run correctly without any error

140
00:15:41,070 --> 00:15:46,830
and with the most and the best ball movement and bouncing.

141
00:15:46,860 --> 00:15:49,200
As you see at this moment.

142
00:15:49,200 --> 00:15:51,030
We reached the end of this lecture.

143
00:15:51,380 --> 00:15:53,630
We enjoyed this lecture and get all of that.

144
00:15:53,640 --> 00:15:56,580
Thank you for watching and thank you for being here.

145
00:15:57,450 --> 00:15:59,900
See you next lecture.
