/
sudokucomponents.hpp
58 lines (48 loc) · 1.5 KB
/
sudokucomponents.hpp
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
#ifndef _SHIROKUMA_COMPONENTS_SUDOKUCOMPONENTS_HPP_
#define _SHIROKUMA_COMPONENTS_SUDOKUCOMPONENTS_HPP_
#include <polarbear/components/components.hpp>
#include <shirokuma/sudokuboard.hpp>
class CellComponent : public BaseComponent<CellComponent>
{
public:
enum class CellType
{
Starting,
Locked,
Free
};
CellComponent(CellType t, int val, int x, int y) :
cell_type(t), value(val), x(x), y(y) {};
CellType cell_type;
int value;
int x, y;
};
class SudokuStateComponent : public BaseComponent<SudokuStateComponent>
{
public:
enum class State
{
Main, // Default state
EnteringValue, // Entering a single value onto the board
EnteringBoard, // Entering the code for a board to be loaded
GameOver // Completed board (quit would exit the game)
};
SudokuBoard board;
State state;
int cursor_x, cursor_y;
};
// Inspired by: https://www.reddit.com/r/gamedev/comments/2rrie6/ecs_and_observer_pattern/cnilgg8
class CursorMovedRelativeComponent : public BaseComponent<CursorMovedRelativeComponent>
{
public:
CursorMovedRelativeComponent(int vertical, int horizontal) :
steps_vertical(vertical), steps_horizontal(horizontal) {}
int steps_vertical, steps_horizontal;
};
class CursorMovedAbsoluteComponent : public BaseComponent<CursorMovedAbsoluteComponent>
{
public:
CursorMovedAbsoluteComponent(int x, int y) : x(x), y(y) {}
int x, y;
};
#endif // _SHIROKUMA_COMPONENTS_SUDOKUCOMPONENTS_HPP_