Fission FSN
Loading...
Searching...
No Matches
gfCSimpleMazeComponent.h
Go to the documentation of this file.
1
2/********************************************************************
3*
4* File: gfCSimpleMazeComponent.h
5*
6* Purpose: Generate a simple maze for random HOG sections
7*
8*********************************************************************/
9
10#ifndef gfCSimpleMazeComponenthdr
11#define gfCSimpleMazeComponenthdr
12
13#include <vector>
14#include <random>
15
17
18public:
19
20 gfCSimpleMazeComponent(int w, int h);
21
22 void print();
23
24 std::pair<int, int> findCell(char contents) const;
25 char getCell(int x, int y) const {
26 if (isValid(x, y)) return maze[y][x];
27 return '#';
28 }
29
30 int getWidth() const { return width; }
31 int getHeight() const { return height; }
32
33 bool isValid(int x, int y) const {
34 return x >= 0 && x < width && y >= 0 && y < height;
35 }
36
37private:
38 int width, height;
39 std::vector<std::vector<char>> maze;
40 std::mt19937 rng;
41
42 // Directions: up, right, down, left
43 int dx[4] = {-1, 0, 1, 0};
44 int dy[4] = {0, 1, 0, -1};
45
46 bool isWall(int x, int y) const {
47 return maze[x][y] == '#';
48 }
49
50 void generateMaze();
51};
52
53#endif
std::pair< int, int > findCell(char contents) const
Definition gfCSimpleMazeComponent.cpp:16
int getWidth() const
Definition gfCSimpleMazeComponent.h:30
gfCSimpleMazeComponent(int w, int h)
Definition gfCSimpleMazeComponent.cpp:86
bool isValid(int x, int y) const
Definition gfCSimpleMazeComponent.h:33
int getHeight() const
Definition gfCSimpleMazeComponent.h:31
char getCell(int x, int y) const
Definition gfCSimpleMazeComponent.h:25
void print()
Definition gfCSimpleMazeComponent.cpp:7