Ok, I'll tell you about the
Hope you understand now
__init__
function. The __init__
function is for defining self variables and sometimes doing a few things. If I create a player class I would do the following:- Make an
__init__
function with parametersself, x, y, width, height, color
- I would define all the variables as goes -
self.x = x self.y = y #etc.
and you can add more variables that aren't in the parameters like thisself.rect = (self.x, self.y, self.width, self.height)
- make a draw function in the player class. It is able to access the self variables defined in
__init__
as long as I put self in the draw parameter.
- Then I save the class in a variables like this
p = Player(paramters)
I don't have to self or anything like that in the parameters because it automatically does that.
- finally to draw it I would call upon the draw function like this
p.draw()
Hope you understand now