-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grid.h
74 lines (57 loc) · 1.7 KB
/
Grid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef GRID_H
#define GRID_H
#include <SFML/Graphics.hpp>
#include <vector>
#include "Cell.h"
#include "Robot.h"
class Grid
{
public:
/** CONSTRUCTORS / DESTRUCTORS **/
Grid(std::vector<Cell *> cells, Robot* robot);
Grid();
~Grid();
/** SETTER **/
void setGrid(std::vector<Cell*> cells);
void setRobot(Robot* robot);
/** GETTERS **/
std::vector<Cell*> getGrid();
bool isOverCell(const sf::Vector2i &mouse);
Cell* getOverCell() const;
/** OTHERS **/
void drawGrid(sf::RenderWindow& window, const sf::Vector2f &grid_pos);
/** FILE STREAM **/
void loadLevel(const std::string &level_id);
void saveLevel(const std::string &level_id, const std::string &level_name);
private:
/** INIT **/
void initLabels();
void initRobotRect();
void initRobot(const std::string &line);
void changeRobotTexture(const Utils::Orientation &orientation);
// All the cells of the grid
std::vector<Cell*> m_cells;
// The robot
Robot* m_robot;
// Radius of the hexagones
int m_radius;
// Gap of the grid in the window
sf::Vector2f m_gap;
// Error handler (prevent from spamming it in the console)
bool m_error_drawing;
// Grid height display
sf::Text m_text_levelheight;
sf::Font m_font_levelheight;
// Grid name display
sf::Text m_text_levelname;
sf::Font m_font_levelname;
// The cell that is currently on mouse
Cell* m_over_cell;
// Rectangle of the robot
sf::RectangleShape m_robot_rect;
// Texture for the robot
sf::Texture m_robot_texture;
// Orientation of the robot (texture will change according to it)
Utils::Orientation m_robot_orientation;
};
#endif // GRID_H