Passing super().init() then calls the init() function of the Sprite class. Passing into the parameters,makes the Player Class it’s child class. Now, this doesn’t really apply to the Player Class, since most games will only have one player but it does apply to the Enemy Class as most games will have multiple enemies. The benefit of using classes here is that we can spawn multiple entities from the same block of code.
#BOA VS PYTHON MOVIE IN UTORRENTS CODE#
Self.image = ("Player.png")Ībove you can see the Code for the Player Class. More about information about Pygame Rects can be found here.ĭISPLAYSURF = _mode((400,600)) The Width (Length) of the Rectangle in pixels.The Y co-ordinate of the upper left corner of the rectangle, also known as the Y co-ordinate from where the Rectangle begins.The X co-ordinate of the upper left corner of the rectangle, also known as the X co-ordinate from where the Rectangle begins.(The order is very important and must not be mixed up). The purpose of each value is shown below in order. Rather than taking a set of co-ordinates like a Circle or Line function does, it takes a tuple containing 4 values. This function takes a rather unique parameter, so we’ll discuss it here. As you can see, this function is used to draw rectangles in Pygame. One thing we didn’t explain earlier was the () function. But it’s just there to you know what one looks like for when we use it later. First of all, in a program with no possible events that can occur, we don’t need a game loop. The Game Loop that we included in this example above is purely for show. When run the above code produces the below window. # Setup a 300x300 pixel display with captionĭISPLAYSURF = _mode((300,300)) Likewise, center_point is the origin point of a circle. The line begins at one set of co-ordinates and ends at another. start_point and end_point represent a set of co-ordinates.width is an optional parameter that determines the size of the outline of the shape.For instance, for a rectangle you will pass a tuple with 4 co-ordinate pairs inside it. The pointlist parameter is a tuple containing co-ordinates or “points”.color parameter is the designated color of the assigned shape.surface parameter is the surface object on which pygame will draw the shape.You’ll get to see some of them being used later on in this tutorial. But we’ll give you a general overview of what these parameters are. We can’t go over each and every function in detail here, you can look up each of them up individually later on if you wish. Due to their similarities, they often share some parameters which they use to create the required shape. Drawing functions are used to create objects in Pygame.