LibCapy - maze

Maze class.

Macros:

Enumerations:

None.

Typedefs:

None.

Struct CapyMaze2D :

Struct CapyMaze2D's properties:

Width of the maze

Height of the maze

Graph representing the maze, nodes are rooms and links are connections between rooms. Node id of room at position (x,y) is equal to (x+y*width)

Struct CapyMaze2D's methods:

Destructor

Genetrate the maze using the origin shift algorithm

Input argument(s):

rng: the pseudo random generator

Output and side effect(s):

Empty the graph if it is not empty, then create a graph equivalent to a 2D maze where rooms are represented with nodes laying on a 2D grid of maze dimensions, and corridors between rooms are represented with links. The maze is guaranteed to have one single path between each pair of rooms. All room are 1x1 in dimension, and all room in the 2D grid exist. The maze contains no loop and no island.

Draw the maze

Input argument(s):

img: the image on which to draw
pen: the pen to draw the maze
dim: the dimension of the maze in the image
pos: the position of the top-left corner of maze in the image

Output and side effect(s):

Draw the maze on the image by drawing vertical and horizontal lines between unconnected rooms.

Functions:

Create a CapyMaze2D

Input argument(s):

width: the width of the maze
height: the height of the maze

Output and side effect(s):

Return a CapyMaze2D

Allocate memory for a new CapyMaze2D and create it width: the width of the maze height: the height of the maze

Output and side effect(s):

Return a CapyMaze2D

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapyMaze2D* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapyMaze2D to free

2024-07-24
in LibCapy,
11 views
Copyright 2021-2024 Baillehache Pascal