-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard_view.h
More file actions
104 lines (76 loc) · 1.86 KB
/
board_view.h
File metadata and controls
104 lines (76 loc) · 1.86 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef BOARD_VIEW_H
#define BOARD_VIEW_H
#include "puzzle.h"
#include "grid.h"
struct view_coord_t {
double x, y, z, angle, tilt;
};
class board_view {
public:
struct tile_color_t {
double r, g, b, a;
};
enum class floor_special_t {
none = 0,
end = 1,
trigger = 2
};
enum class robot_beam_t {
off = 0,
hits_floor = 1,
hits_nothing = 2
};
struct floor_info {
tile_color_t color;
double opened = 0.0;
floor_special_t special = floor_special_t::none;
};
using grid_t = grid_tpl<floor_info>;
inline const grid_t &
grid() const noexcept { return grid_; }
inline const view_coord_t &
robot_pos() const noexcept { return robot_pos_; }
static tile_color_t
get_alternative_tile_color(std::size_t index);
static tile_color_t
get_trigger_tile_color(std::size_t index);
void
set_robot_pos(double x, double y, double z, double angle, double tilt, double wheel_rot);
void
set_robot_beam(robot_beam_t beam);
void
set_obstacle_pos(int index, double x, double y, double z, double angle, double tilt);
void
clear_obstacle(int index);
floor_info &
modify_floor(int x, int y);
void
clear_floor(int x, int y);
void
draw(std::size_t width, std::size_t height, double global_phase) const;
void
draw(
std::size_t screen_width, std::size_t screen_height,
std::size_t x0, std::size_t y0,
std::size_t x1, std::size_t y1,
double global_phase) const;
void
reset(const puzzle & puz);
private:
void
draw_floor_tile(int x, int y, const floor_info & floor, double global_phase) const;
void
draw_robot(const view_coord_t & coord) const;
void
draw_obstacle(const view_coord_t & coord) const;
void
draw_board(double global_phase) const;
view_coord_t robot_pos_ = {
1., 0., 0., 0., 0.
};
double robot_wheel_rot_ = 0.;
robot_beam_t beam_state_ = robot_beam_t::off;
std::map<int, view_coord_t> obstacle_pos_;
grid_t grid_;
};
#endif