-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtile.h
62 lines (51 loc) · 1.28 KB
/
tile.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
#ifndef __inc_tile_H__
#define __inc_tile_H__
#include <SDL.h>
#include <optional>
#include "directions.h"
#include "helper/renderer.h"
/* from map.txt
0 : empty (we could possibly go here)
1 : wall
2 : dot
3 : power dot
4 : ghost house door
5 : portal
6 : bonus
9 : start position
*/
enum class TileType {
EMPTY,
WALL,
DOT,
POWER_DOT,
GHOST_HOUSE_DOOR,
PORTAL,
BONUS,
START_POSITION = 9 // so that we can use static_cast<TileType>(9)
};
class Tile {
private:
TileType m_type; // type of the tile
int m_i, m_j; // position of the tile in the array
double size; // size of the tile
public:
Tile() = default;
Tile(const int type, const int x, const int y, const double size);
~Tile() = default;
/// @brief the type of the tile
TileType get_type(void) const;
/// @brief set the type of the tile
void set_type(const TileType &type);
/**
* @brief show the tile on the screen
*
* @param renderer the renderer to use
*/
void show(std::shared_ptr<Renderer> renderer);
/// @brief can we go to the target tile (as pacman)?
bool can_go(const std::optional<Tile> &target) const;
/// @brief can we go to the target tile (as a ghost who can go through doors)?
bool can_go_ghost(const std::optional<Tile> &target) const;
};
#endif // __inc_tile_H__