Maze
- class quest.examples.maze.MazeGame[source]
Get all the stars as fast as you can! My record is 45 seconds.
MazeGameis an example of how you can make a fairly complex game without making too many changes. BecauseMazeGameis a subclass ofQuestGame, we just need to change the parts we want to work differently. We need to set some of theMazeGameproperties and override a few of the class methods.To run this example:
$ python -m quest.examples.maze
After you play it, check out the sorce code by clicking on “source” in the blue bar just above.
- tile_size=32
Each square tile in the map is 32 pixels across.
- grid_columns=33
The map will have 33 columns of tiles.
- grid_rows=33
The map will have 33 rows of tiles.
- player_sprite_image="images/boy_simple.png"
The sprite’s image file.
- player_scaling=0.5
The image is too big, so we scale it down. (We could also just resize the image itself.)
- player_initial_x=1.5 * tile_size
By starting the player at 1.5 times tile_size, the player will initially be positioned at the center of tile (1, 1). The outer edge of the map is walls.
- player_initial_y=1.5 * tile_size
Again, centering the player at (1, 1)
- score=0
Keeps track of how much loot has been collected.
- max_score=25
Total amount of loot to be distributed through the maze.
- game_over=False
Keeps track of whether the game has ended.
- class quest.examples.maze.Loot(filename=None, scale=1, image_x=0, image_y=0, image_width=0, image_height=0, center_x=0, center_y=0, repeat_count_x=1, repeat_count_y=1, flipped_horizontally=False, flipped_vertically=False, flipped_diagonally=False, hit_box_algorithm='Simple', hit_box_detail=4.5, texture=None, angle=0)[source]
Loot is a NPC which shows up in the game as a star. Its only job is to get collected by the player.
- class quest.examples.maze.MazeMap(columns, rows, tile_size, num_loot)[source]
A Map which creates a wall layer using a
Maze.MazeMapis a subclass ofMapwhich automatically generates a maze. It uses aMazeto figure out where to put walls, and adds wall sprites to a map layer in a corresponding pattern. :param columns: The number of columns of tiles in the map :param rows: The number of rows of tiles in the map :param tile_size: The size (in pixels) of each square tile :param num_loot: The number of loot sprites to add to the map- generate_maze(seed=None)[source]
Generates (or re-generates) the map. The
Mazedoes most of the work.Regenerates the maze, clears the wall map layer and the loot map layer (in case there was a previous maze), and then populates these layers with new wall sprites and loot sprites.
- Parameters
seed – Random seed to pass to the maze (see
Maze.generate())