1
00:00:00,300 --> 00:00:01,300
Hi, welcome back.

2
00:00:01,980 --> 00:00:13,440
And this video, we will learn how to add the moving belt, so we will load the image using pygame fettucini

3
00:00:13,500 --> 00:00:23,990
as the following four words equal by game image, dot loop between two parentheses, as we said before,

4
00:00:24,330 --> 00:00:28,780
and to think it has its last yellow there.

5
00:00:29,120 --> 00:00:41,880
But then add the converse method to the back end of image upload method, which used to make our image

6
00:00:42,610 --> 00:00:46,320
loaded without any arrows for without any shadow.

7
00:00:46,740 --> 00:00:56,140
Now we will create a rectangle around the belt by using the direct method of my game as a whole.

8
00:00:56,240 --> 00:01:06,630
So that underscore rectangles equal but don't get hundreds correct between two buttons that center equal

9
00:01:07,880 --> 00:01:09,170
to possession.

10
00:01:10,400 --> 00:01:20,680
X and Y, two hundred for X and two hundred fifty five for right now, we can use by Gameboard Method

11
00:01:20,750 --> 00:01:25,400
to make our best showing at the game display.

12
00:01:25,430 --> 00:01:27,110
So game on.

13
00:01:27,110 --> 00:01:34,670
The court is delayed or buried between two, but that is fair and square rectangle.

14
00:01:35,180 --> 00:01:43,730
Now let's build our policy and our values are correctly added to the game is three game play.

15
00:01:43,870 --> 00:01:53,090
So we need to change our allocation to be at the left of our game three and two, that we will change

16
00:01:53,300 --> 00:02:02,400
the value to handle it and get that message to one hundred and build our goals in the game and will

17
00:02:02,420 --> 00:02:09,860
run correctly with the bat nearly in the middle of our screen.

18
00:02:09,860 --> 00:02:12,650
So we will change the one hundred to.

19
00:02:17,000 --> 00:02:29,530
Which is more accurate and more convenient, but I found that the best value for that number is 25,

20
00:02:30,560 --> 00:02:42,230
as you see when we outgrows it at the start of the left of our game display, our game is great.

21
00:02:43,710 --> 00:02:46,370
Now we want to move our bid.

22
00:02:46,670 --> 00:02:57,380
And to do that, we need to add to your variable gravity and bad movement so the gravity will equal.

23
00:02:58,500 --> 00:03:11,730
Four by two, which is also our game, and our first four, we reset the gravity at a value equal four

24
00:03:11,730 --> 00:03:24,990
point two and belt and the school movement will be reset at a value equal zero, then use these variables

25
00:03:24,990 --> 00:03:34,320
inside the event handler function to be equal with our y loop or game loop at the following, so that

26
00:03:34,320 --> 00:03:38,100
underscore more plus equals gravity.

27
00:03:38,940 --> 00:03:48,960
Now we built our logic to ensure that our project work correctly with new added variables.

28
00:03:52,720 --> 00:03:55,080
But we get two errors.

29
00:03:55,450 --> 00:04:06,700
This is because we should cancel the event handler function and make all the content inside this function

30
00:04:07,360 --> 00:04:12,390
to be inside our game loop to avoid these errors.

31
00:04:13,180 --> 00:04:19,090
So I will copy all lines of code inside the event handler function.

32
00:04:20,990 --> 00:04:32,840
And cut it and pasted inside the while loop or the game loop instead of even hand or method as they

33
00:04:32,840 --> 00:04:41,990
followed and run our project again after that to ensure that our game is run correctly without any errors

34
00:04:42,980 --> 00:04:50,170
that were corrected, without any harm and the correct clap movement of our ballot, as you see.

35
00:04:50,180 --> 00:04:59,840
So we use the word underscore rectangles that center y the last equal word, the movement to move the

36
00:04:59,840 --> 00:05:03,660
ball forward continuously without stopping.

37
00:05:03,830 --> 00:05:12,090
And also, we can control the flow of movement by using the space K using pygame, not even to type

38
00:05:12,110 --> 00:05:13,040
as the following.

39
00:05:13,250 --> 00:05:25,910
If even the type that will equal by game that K down column f even dot k love in equal by game dot k

40
00:05:25,910 --> 00:05:39,410
capital underscore its base column so well and the school movement minus 10 to move upwards the opposite

41
00:05:39,410 --> 00:05:47,210
to our gravity, OK, and build our project again to ensure that flat movement is OK.

42
00:05:47,360 --> 00:05:58,820
But there is a problem that the world well flat outside the screen are both OK and will change that

43
00:05:58,820 --> 00:06:04,070
movement by minus 15 and build our project again.

44
00:06:04,790 --> 00:06:15,860
It will run correctly with the normal flair movement, but still go outside of life outside our game

45
00:06:15,860 --> 00:06:19,230
screen or our game play, as you see.

46
00:06:19,760 --> 00:06:23,000
So when we run the game, it will run.

47
00:06:23,510 --> 00:06:32,330
But our bill containing Flashbang until it will exit the game display, we can solve this issue by ad

48
00:06:32,330 --> 00:06:38,300
one line of code to adjust their movement before the game running.

49
00:06:38,450 --> 00:06:48,110
So to do that, we will we will firstly change the position of our variables to be at the top of our

50
00:06:48,110 --> 00:06:56,750
code after the pygame initiation and run our Brossette again to ensure that we don't have any errors.

51
00:06:57,020 --> 00:07:07,400
We can adjust our movement to minus 15 to get the best flat movement of the belts.

52
00:07:08,210 --> 00:07:17,720
And I will change also the gravity to be equal four point twenty six OK, which is more appropriate

53
00:07:17,720 --> 00:07:32,480
for our game and run game again and to run correctly without any errors, but still the bad of outside

54
00:07:33,320 --> 00:07:35,450
our game display.

55
00:07:36,620 --> 00:07:45,080
And we can correct the error of living outside the game screen to adjust the belt movement again to

56
00:07:45,080 --> 00:07:54,140
zero after each collapse and we build our Brusic again and we find that our problems have been gone

57
00:07:54,590 --> 00:08:02,420
and we will adjust to their underscore movement to minus equals eight point five and build our brusic.

58
00:08:02,420 --> 00:08:04,640
It runs smoothly and OK.

59
00:08:05,330 --> 00:08:09,350
So at this point we reached the end of this lecture.

60
00:08:09,350 --> 00:08:13,430
I hope you enjoyed this lecture and get all of that.

61
00:08:13,850 --> 00:08:16,690
Thanks for watching and thanks for being here.

62
00:08:17,480 --> 00:08:18,170
See you.

63
00:08:18,170 --> 00:08:19,520
Next lecture.
