Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
grid.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <vector>
6
7class Grid {
8public:
9 /* Constructors and Destructors */
10
11 Grid() : Grid(0, 0) {}
12
19 Grid(int rows, int columns);
20 ~Grid();
21
22 /* GridCell CRUD */
23
38 void addCell(int x, int y, CellType type);
39
50 GridCell* getCell(int x, int y);
51
52 /* Getters and Setters */
53
58 int getRows() const;
59
64 int getColumns() const;
65
70 std::vector<std::vector<GridCell*>> getGrid();
71
76 std::vector<GridCell*> getSpawnPoints();
77
82 glm::vec3 getRandomSpawnPoint();
83
92 glm::vec3 gridCellCenterPosition(GridCell * cell);
93
94 void writeToFile(std::string path);
95
96 /* Static members */
97
101 static float const grid_cell_width;
102
113 static glm::ivec2 getGridCellFromPosition(glm::vec3 position);
114
125 static std::vector<glm::ivec2> getCellsFromPositionRange(glm::vec3 p1,
126 glm::vec3 p2);
127
128private:
129
133 int rows;
134
138 int columns;
139
144 std::vector<std::vector<GridCell *>> grid;
145
149 std::vector<GridCell*> spawnCells;
150};
CellType
Definition: celltype.hpp:3
Definition: gridcell.hpp:23
Definition: grid.hpp:7
void writeToFile(std::string path)
Definition: grid.cpp:93
GridCell * getCell(int x, int y)
Attempts to retrieve a GridCell at the specified location. Note: This function asserts if the coordin...
Definition: grid.cpp:45
void addCell(int x, int y, CellType type)
Adds a GridCell of the specified type at the given location. If the type is CellType::Spawn,...
Definition: grid.cpp:25
std::vector< std::vector< GridCell * > > getGrid()
Returns the 2-D GridCell vector maintained by this Grid.
Definition: grid.cpp:66
~Grid()
Definition: grid.cpp:21
Grid()
Definition: grid.hpp:11
static float const grid_cell_width
The width, in meters, of each GridCell in this grid.
Definition: grid.hpp:101
glm::vec3 getRandomSpawnPoint()
randomly selects a spawn point
Definition: grid.cpp:74
std::vector< GridCell * > getSpawnPoints()
Returns the vector of spawn point GridCells in this grid.
Definition: grid.cpp:70
glm::vec3 gridCellCenterPosition(GridCell *cell)
Returns the center position (as an Object position vector) of the given GridCell's center.
Definition: grid.cpp:82
int getRows() const
Returns the number of rows in this Grid.
Definition: grid.cpp:58
static std::vector< glm::ivec2 > getCellsFromPositionRange(glm::vec3 p1, glm::vec3 p2)
Returns a vector of positions of GridCells that contain the rectangle that extends from p1 to p2 (ass...
Definition: grid.cpp:132
int getColumns() const
Returns the number of columns in this Grid.
Definition: grid.cpp:62
static glm::ivec2 getGridCellFromPosition(glm::vec3 position)
Returns the position of the GridCell that would contain the given position.
Definition: grid.cpp:116
GLint GLenum GLint x
Definition: glad.h:1655
GLint y
Definition: glad.h:1516
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glad.h:1531