Rapid Pygame provides a level manager that keeps tract of level and is capable of level parsing
Responsible for handling player movement and level related collision detection. The structure of a level can be found in Level format
Contains the interpreted level and methods that should be called every frame to update the level. Also handle player movement. Since the interpreted level is exposed, the built in movement method doesn’t have to be used. The movement methods can be overridden by a child class to achieve a different movement effect. Note that if the child class has a different constructor, the LevelManager will have to be sub classed as well.
Parameters: |
|
---|
This method is called every update cycle to simulate gravity. Override this method to produce different behavior
This method is called to decide when a jump is possible
Param: | movement: The movement dict forwarded from update() |
---|---|
Return type: | bool |
Find the rect with the largest y in the rect_list
Find the rect with the lowest y in the rect_list
Get the width and height of the level
Returns: | (width, height) |
---|
Interpret the level, breaking it down into a list of rect that should collide with the player. Whether a tile collides with the player or not is specified in the level file. See Level format for more details
Returns: | A list of rects |
---|---|
Return type: | [Rect] |
This method should be called every frame to update the location of the player and the environment. Player‘s start_jump() and jumping is used to start the jump and check if a jump is in progress, respectively.
Parameters: | movement – Dict with keys up, down, left, right mapping to booleans |
---|
A list of tuples, that are (surface, rect). Drawing the whole list with display_surf.blit(*level.draw_list) will draw the background, level, and player
Exit of the level. (x, y) None if unspecified in the level
A list of rects that should collide with the player, see interpret()
Spawn point of the player (x, y)
Load and manage levels.
Takes a path to the level file and the player object to manipulate
Parameters: |
|
---|
Return type: | Level |
---|
Load a level relative to the origin
Parameters: | path – Path to the level in list format |
---|
Advance current_level
Set current_level to the previous level
Current level object, set by using next_level() and previous_level()