Hi, welcome back.
In this video, we will complete funkin and learn how to add paddleboards to the game display.
So let's do that.
So we will use by game module to create the puzzle sprites.
So Spight is an object, have different probers like Waitz, height, color and extra.
Also sprites have methods, jump, height, more forward and so on.
So by creating the first Seasprite, we were to implement and use object oriented programming.
So we will create a class for our paddles and get the two objects battle won and battle to from battle
class.
Thus, as multiplayer game contains two players, so every player will be able to control his battle.
So battle one four, player one and battle two four.
Player two.
So we will create another file called Paddle By.
Was small P and save this file, battled by as by filing in our folder bonke as the following.
Then orbit the file and I'm bored by game, then we need to assign a variable called black, which contain
a total of three integers, zero and zero and zero.
We will try to convert this black variable from one goodbye module that we work on it in the first lecture.
Then now we will create a class called Battle with the Capital as the following class battle between
two parentheses pygame dot bright dot bright with as capital.
Then close the parentheses and column.
Then we will add the constructor method inside the class battle to initiate those characters as the
following def double underscore and double underscore in parentheses and self comma color comma with
comma height.
Close parentheses.
Then add column, then we will call the parent class constructor as the following Zober Dot Navot underscore
and it doesn't underscore.
Bob and parenthesis, close parenthesis now.
We want to lessen the color of the battle and it's X and Y position and width and height and also set
the background color and set it to be.
Transparence.
So self image equal by game dot surface.
Between two entities.
A list of width and height separated by comma.
Self image.
Between two parentheses, black and self-taught image said underscore Caraquet between two parentheses
black, now we will draw battles using draw the direct method as the following pygame dot draw dot recht
between two parentheses self image, comma, color, comma and bobin square brackets zero and zero and
with comma height.
Close the square brackets and close the parentheses.
Then we will adjust the rectangle object that has the dimensions of image.
So self destruct, equal self image.
Don't get under correct between two parentheses, nothing, no parameters in this method, so the Salvador
track will equal to the self image.
Don't get the object or mass.
Now we will build our Brozak to run our game and see if our code is run correctly.
We find that we have an error that is the variable blank is not imported from BONKE, so we will assign
it again.
But in this battle, the fire has the following, so we will remove the import statement from BONKE
and bought black, then black equal hateable of zero zero zero.
Close the table.
Now we will build our product again to run our game to see if it's run correctly or not.
It will run correctly and without any problems.
Then we will complete our code inside the battle by fire as a following by defining a function called
models.
Underscore moving underscore up which is responsible for moving.
Our battle up will take two parameters self and number of pixels.
So D.F. models underscore moving underscore up between two parentheses self and number of pixels on
a number.
And also underscore of underscore pixels, close parentheses column, then inside this function, we
will assign self-taught rect dot y minus equal number underscore of underscore pixels and the check
if we are not going too far of the game display.
And to do that, we will use every statement as the following f self-taught rect dot y less than zero.
Column, so self-doubt wrecked dot y equals zero, and we will define another function called battles
underscore, moving, underscore down to control and move our battles down by the plate.
So we will copy the first function as a following and paste it at the same ID again and change it to
battles move down instead of up.
So we have now to function or we defining two functions that able to move our battles up and down and
control it by the players.
But in case battles underscore moving town function, we will change that and f statement.
If self doubt react that way, more than 600 column self dot dot y equals six hundred bexell.
Now we've finished shooting but also by fire.
So we will build it to see if we have any errors in this file at the following.
But firstly we will on board battle in the main point by fire as the following from battle and board
battle with B capital.
Then we will declare Battle one and battle two to be assigned to the object of battle class as the following.
So battle one equal battle between two parenthesis white comma, then comma and then close parentheses.
Then we will.
And the same for battle two will be assigned as object of battle class.
So will equal battle between two entities white and the comma and then and comma and one hundred close
parentheses.
Then we will add the two coordinates for battle one and battle two.
So battle one dot red dot X equals twenty five and one dot dot Y equals two hundred and fifty.
Also for battle to dot dot x coordinate equals seven hundred seventy five and battle to attract dot
y coordinate equal two hundred and fifty.
Now we will create a list that will contain all Sprite we want to use in one game sprite underscore
list equal by game dot dot group and and open and close to empty.
Then we will add the two bottles to the sprite less so the sprites underscore less dot add between two
parentheses by the one and try underscore last dot add between two parentheses battle to and add the
same indentation of the for loop we will add kaze variable equal by game dot k dot get underscore press
method and we will add four F statements to control the borders up and down using W and S and up and
down in case at the keyboard by the player.
So F K is between two square brackets by not K capital.
Underscore w k.
Collum battle won that battles moving up.
Measured by seven pixels and we will copy the F statement that we created and bested three times again
and change these additional three F statements to control the moving up and moving down of the two battles.
So for the second statement will be F K is between two square brackets dot k underscore s.
But the one that.
Battles move, underscore, moving, underscore down between two Prentice's seven.
And for the third one, if case between two square brackets by game dot k underscore up.
In other case, letters so vital to the battles moving up.
Between two parentheses seven and for the first one.
If statement if case between two square brackets.
By game dot k underscore down and other case characters or letters column battle to dot battles moving
down between two parentheses seven.
Now we will build our logic to run our game and see if it run correctly or not.
It runs with error.
This error due to a battle that by we forget to add the two parentheses of get wrecked method.
Now we will run the game again by building our logic and our game run perfectly and our battles are
moving correctly without no errors.
And at this moment we reach the end of this lecture.
Hope you enjoyed this lecture and get all of that.
Thanks for being here and thanks for watching.
See you next lecture.