Hi, welcome back.
In this video, we will add pilots to the game display and make it is born every time Bériot as the
following.
In the first lecture of this section, we created the by Celeste and make random module able to choose
one type of the two types of these Vibs.
Now we will change the variable name, which called buy into my service as a following, so by underscores
or equal buy game dot image dot between two parentheses, random Dota choice and inside the sound bytes
underscore lest.
Then we will create an empty list called Vibe's list to the following, so perhaps underscore less to
equal empty to square brackets.
Then add a new variable called So Underscore five, which will equal pygame, game, dot user, even
all character of user event are in capital case.
This variable will equal user event in capital case, which will be activated by a timer.
So we need to create a timer and we can create a timer by using by game the time the set time method
as the following by game.
The time dot set on the timer between two parentheses so underscore by comma one thousand milliseconds
then an event handler function.
We will add the following code to solve that by using new statements.
So if event dot type doesn't equal so underscored by column by underscore less to not have been between
two parentheses adding by a method or function.
So our empty list will be filled with the idea of the adding by function.
So now we need to create this new function, add the first part of the code with other functions and
the following.
So def adding underscore pipes and to empty parentheses column.
Then inside the function we will add new by equal by the get the track between two parentheses method
which are the half of the game display dimension.
So method equals a table of X and Y position which are three handwriting and comma and two hundred fifty
five.
Close the parentheses then in the second line inside the function we will add return new by then add
new function to move the bytes as the following d.f. by underscore and move between two parentheses
pipes then add column then inside the function as a follow for byte imbibes column.
By the center X minus five.
Then return VIPs and a new line inside the function, this function will take every VIPs list and move
at by minus five pixels in the x axis.
So it will move to the left, then return and new list of pipes.
Now, in the event handler function, we will add VIPs underscore less to equal five underscore move
between two parentheses by underscore less to then and a new line.
We will also underscore bypass function as a following.
So underscore Vibe's and the add to empty parentheses of the method.
Now we need to create the show.
Pipes function as the following def so underscore vibes between two parentheses by column.
Then inside the function we will add a for loop, the following for item and bytes column.
And inside this four loop we will add this line of good game underscore display belet between two parentheses
by service and by now we will try to build out Brusic to see if we have any errors in our code.
So let's build it.
We have an error due to using time instead of time.
And by the time the set time, not the time set time, we will change it from time to time and run the
project again and we get another two errors.
The first error, the two we have to change.
The assignment of pipes underscore later to to Vibe's underscore move method to to be inside the game
loop as the following.
And the second error is due to we forget to add the parameter offshore method as the following so underscore
by between two, parentheses by list two.
Then we will build our music again to see if we will have other errors again.
And if you focus on the game screen, you can observe the frequency of adding new bytes are very fast.
So we will adjust this frequency by using by game the time that the time and method to change the parameter
of one thousand milliseconds to seven hundred and fifty milliseconds only and build the project again,
it will run with the correct frequency of adding new bytes.
Also, we will change the speed, the take from one hundred milliseconds to 80 seconds.
And after running the project again, it will run smoothly without any error.
And with the correct games beat, you can set a timer to 800 or 900.
Both times are perfect for our game, 800 or 900 milliseconds, as you see, I will build the project
again after changing the eight hundred seconds to 900 seconds as the following.
And it will run perfectly with this time.
We have added the bottom fives and we need now to add.
Zettabytes as the following, so and so by its function, we will add if statement as the following
if pipes.
That bottle, more than five hundred and ten collomb, so if by the bottom more than or equal, five
hundred and ten, which is that is Billey High as you see.
Game, this delay, though, delayed by service and underbite, so the game will show the bottom by
in case of the vibe, the bottom more than or equal.
Five hundred and ten, which are the heart of the game screen, all game display, or else it will show
the reverse pipes or the top pipes.
So El Collomb reverse underscored by equal by game to transform not between two parentheses by service
and false and true.
So we will add another pipes list but in reverse position or top position of the game display and use
transform just up to flip the pipes left and the Y axis only by adjusting its value to true then cobie
the game underscore displayed the method and visited in the second line after requests by party change
the pipe service.
We will belet the reverse pipe.
OK, now we need to add random positions of the pipes inside the adding by function as the following
random underscore pipe underscore height equal random choice between two parentheses by underscore.
Right now we need to assign heights as a variable as the following pipe.
Underscore height equal a list of values which are one hundred and fifty comma.
Two hundred and fifty comma, three hundred and fifty.
Then we copy the line of code of new by inside the adding bypass function and paste it again and rename
the first one to the base pipe and second one to top pipe.
And the change the top of the base pipe to the bottom and the return the to bypass the base pipe and
the top pipe and to avoid the error of showing the two pipes on each other.
We will change the base pipe and to make bottom equal to handle the eight and random pipe height and
and will do the same thing for top pipe.
And in case of base VIPR, we will subtract two hundred pixels from the random by height and the following
to return a table of the two vibe's top and the base.
We will change Aben to extend and build our Brusic to run correctly with one problem only that the top
five is incorrect direction.
So what we can do to avoid this error, we firstly will change the two hundred to one hundred and fifty
pixels only and build our project again.
So the distance between the two pipes are appropriate and we will change the heights to two hundred
and two and three hundred and 400, which is more appropriate for our pipes.
As you see.
OK, now we solve the problem of the wrong direction of our pipes as the following, we will return
to the show by its method or function and change it.
So for imbibes column and pipe the bottom more than or equal five hundred and ten column game display
the belt between two parentheses five serves and five ls column the words underscored by equal by game
to transform not fill up between two parentheses.
By service, comma, fourth, comma through.
In the second line game underscored display the pellet between two parentheses, reverse, underscore
by and by and run our project again and it will run correctly without any errors, with the correct
height of the top and the base pipes and also with the correct base between the two by the top and the
base.
And also and also we observe that the direction of the top and the base vibes are correct.
OK, at this point we reach the end of this lecture.
Hope you enjoyed this lecture.
And to get all of that, thanks for watching and thanks for being here.
See you next week.