Hi, welcome back.
And this video, we will learn how to add the moving belt, so we will load the image using pygame fettucini
as the following four words equal by game image, dot loop between two parentheses, as we said before,
and to think it has its last yellow there.
But then add the converse method to the back end of image upload method, which used to make our image
loaded without any arrows for without any shadow.
Now we will create a rectangle around the belt by using the direct method of my game as a whole.
So that underscore rectangles equal but don't get hundreds correct between two buttons that center equal
to possession.
X and Y, two hundred for X and two hundred fifty five for right now, we can use by Gameboard Method
to make our best showing at the game display.
So game on.
The court is delayed or buried between two, but that is fair and square rectangle.
Now let's build our policy and our values are correctly added to the game is three game play.
So we need to change our allocation to be at the left of our game three and two, that we will change
the value to handle it and get that message to one hundred and build our goals in the game and will
run correctly with the bat nearly in the middle of our screen.
So we will change the one hundred to.
Which is more accurate and more convenient, but I found that the best value for that number is 25,
as you see when we outgrows it at the start of the left of our game display, our game is great.
Now we want to move our bid.
And to do that, we need to add to your variable gravity and bad movement so the gravity will equal.
Four by two, which is also our game, and our first four, we reset the gravity at a value equal four
point two and belt and the school movement will be reset at a value equal zero, then use these variables
inside the event handler function to be equal with our y loop or game loop at the following, so that
underscore more plus equals gravity.
Now we built our logic to ensure that our project work correctly with new added variables.
But we get two errors.
This is because we should cancel the event handler function and make all the content inside this function
to be inside our game loop to avoid these errors.
So I will copy all lines of code inside the event handler function.
And cut it and pasted inside the while loop or the game loop instead of even hand or method as they
followed and run our project again after that to ensure that our game is run correctly without any errors
that were corrected, without any harm and the correct clap movement of our ballot, as you see.
So we use the word underscore rectangles that center y the last equal word, the movement to move the
ball forward continuously without stopping.
And also, we can control the flow of movement by using the space K using pygame, not even to type
as the following.
If even the type that will equal by game that K down column f even dot k love in equal by game dot k
capital underscore its base column so well and the school movement minus 10 to move upwards the opposite
to our gravity, OK, and build our project again to ensure that flat movement is OK.
But there is a problem that the world well flat outside the screen are both OK and will change that
movement by minus 15 and build our project again.
It will run correctly with the normal flair movement, but still go outside of life outside our game
screen or our game play, as you see.
So when we run the game, it will run.
But our bill containing Flashbang until it will exit the game display, we can solve this issue by ad
one line of code to adjust their movement before the game running.
So to do that, we will we will firstly change the position of our variables to be at the top of our
code after the pygame initiation and run our Brossette again to ensure that we don't have any errors.
We can adjust our movement to minus 15 to get the best flat movement of the belts.
And I will change also the gravity to be equal four point twenty six OK, which is more appropriate
for our game and run game again and to run correctly without any errors, but still the bad of outside
our game display.
And we can correct the error of living outside the game screen to adjust the belt movement again to
zero after each collapse and we build our Brusic again and we find that our problems have been gone
and we will adjust to their underscore movement to minus equals eight point five and build our brusic.
It runs smoothly and OK.
So at this point we reached the end of this lecture.
I hope you enjoyed this lecture and get all of that.
Thanks for watching and thanks for being here.
See you.
Next lecture.