Welcome back.
And this video, we will create floppy fair game clone, so end of our game overview section.
We learn how to create a game with a black screen and how to make our could include that with method
which used X or Q or in the case of the player or the user.
Now we will covid this code set in the sublime tickets.
Ed has the following and after we finish and the process, we can now use these lines of code to be
the starter code for our game and modify that.
So let's begin then.
We will save this file as.
Lobby that by 5:00, we shall ensure that our best system is passed.
And our view, Centex also is biased now we can run our program to ensure that.
Our game or our code is run correctly as the follow fell out logic and to run correctly without any
problem, the first modification to adjust the resolution to be as a following, which equals four hundred
pixels and height, equals six hundred and fifty pixels and run our game by bending over again to run
correctly with the new resolution, as you see.
Then we will involve the random Python Library or module.
So and the third line we will type in bold, random.
And run our project again, and it will run pretty fine without any problems and closed the game window.
Now we will use the random module to load the VIPs images from the fireplace as the following.
So we will create a list of pipes, images, then loses list using by game and random module.
And the following VIPs underscore less equal between two square brackets and two parentheses for the
first image which exists and site assets slashed by.
There's green, there's bank, and the other image exists and assets slashed by.
Slashed by the red dot bank, closed the central coast and closed the square brackets, then we will
assign the pygame, the image that lood method.
To a variable called by underscore service, saw by underscore surface, equal by game dot image, the
cloud between two parentheses random Dota choice and inside the random choice method by underscore inside
the two parentheses of this method.
Now we will build our program to run our game to ensure that everything is run correctly.
OK, I could run correctly without any problem, as you see now.
We will change the game name from my game to Willoughby Pale Clone, then we will adjust the speed of
the game.
Through creating a new variable called speed, which will equal or assigned to by game, the time dot
clock method was seed capital.
Don't worry, I will change the C small of the clock to the seed capital letters.
The next step to call the speed variable inside the wire loop or the game loop which contains the game
dot the time that clock method or object as a follow.
So speed dot text method which will be used to call by game the time the clock object or method to adjust
the game speed at one hundred milliseconds.
Then we add the background by assign a variable called background to two by game dot image dot load
method.
And inside the two parentheses of this method, we will add the background asset position at our folders
which exists inside the access file.
So background, equal pygame, dot image, dot loop between two entities, assets, class backgrounds
that day the bank and close the parenthesis.
Now we can use the game, underscore display belet method to add our background on our screen or our
game display service as a.
So game underscore display the delay between two parentheses, background and comma and a table of zero
and zero.
This table of zero and zero refer to of the start of the X and Y position of our background.
Close the parentheses and build our project again to see the result.
And after running our game, we found that the X and Y position start correctly, but end end correctly.
We will adjust the width and the height of our project to ensure that the background fits our game display
or our screen.
So the weights will be and the eighty five and our height will be equal.
Five hundred and ten pixels as we said before then we need to add that convert method to the background.
To be the background equal or assigned to buy a game, the damage, the clothes, the asset that convert
metal, as you see, then we build our project to run our game and it runs correctly without any error
and with the correct size of our background.
Then we add the base has it as the following base equal by game dot image to cloud the position of the
asset or where is as it exists in our folder that converts.
Then we need to add this base to the game display or our screen by using game underscore display the
valid method between two parentheses base and a table of zero and zero, which is the X and Y position
which our base asset will start from, then build our blowsy and we see that the base asset is in wrong
position at the top instead of the bottom of the game display or the game screen.
So we will use the table inside the appellate method which express the X and Y position, which will
update only the position as the exposition is OK.
So game underscore display the ballot between two parentheses based comma a of zero and four hundred
and run our game.
It runs correctly with the correct position of the base exit, but we want to perfectly adjust the position
of the base exit so we will change the four hundred to three hundred and fifty adds of our position
and build our Beroza and the base exit style and the wrong position.
So I will use four hundred and thirty five, which is after we build the project, we find that the
Y position fit our game, display our game screen more than four hundred and twenty as you see.
After that we will build it again and observe that the base position is the most appropriate position
for our game screen, for our game display.
Now we want to move this base to make the game look active so we will use the base X position to move
this base and the changing the position of the game base from zero to the base X position.
Now we will add a variable called base underscore X underscore position equals zero.
Then inside the game we will decrease this variable by minus one bexell then build our Brusic again
and the base as it moves from the right to the left, then disappear.
And to prevent the disappearance of our base, we will create a function called Base Underscore Move,
which will contain two or darville assets of our base as a follow and also add if statement inside the
game loop if base underscore x underscore position let then minus two hundred eighty five column so
base underscore X underscore position equals zero.
Then build our project again and the game base is still not moving.
So we will change the statement as the following.
If base underscore X underscore position less than or equal minus two hundred eighty five which is the
width of our game display column base underscore exposition equals zero and run our project again had
to run fine without any problem with the base moving without disappearing at this point which the end
of this lecture.
I hope you enjoyed this you and get all of that.
Thanks for watching and thanks for being here.
See you next with you.