I am creating a maze game with bevy.
The image is that maze. Each green dot represents a MazeNode and the arrow is a pointer to its parent:
#[derive(Component)]
struct MazeNode {
position: Vec2,
parent: Option<Entity>,
}
The nodes and its parent are build in a way that the maze is a root directed tree. Meaning that if you follow the arrows, starting from any node, you will end at the root.
The maze is saved with a resource:
#[derive(Resource, Debug)]
pub struct Maze {
pub root: Entity,
pub grid: Vec<Vec<Entity>>,
pub cell_size: f32,
}
In the game, the green dots and the arrows will not be visable for the user. (just for debug)
The way I draw the maze itself is as follows:
Setup: Draw a big white square the size of the maze.
Update: Draw paths for every node to its parent.
This way I dont have to store the children of each node too.
Now I want to introduce collision to the walls. I added rapier to the project.
The problem is that I dont render the walls, I render the paths and that makes it looks like I render the walls.