summary refs log tree commit diff stats
path: root/src/game.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-06-05 21:02:51 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-06-05 21:02:51 -0400
commit3fa9af58bc907048a8ccadc2bef7736ec554a09d (patch)
tree00bca7856629dcd4f9d2846433c37ab18d651d13 /src/game.h
parent5e94c9fb603dc4648fe6ab4c153ba4114b6bb486 (diff)
downloadether-3fa9af58bc907048a8ccadc2bef7736ec554a09d.tar.gz
ether-3fa9af58bc907048a8ccadc2bef7736ec554a09d.tar.bz2
ether-3fa9af58bc907048a8ccadc2bef7736ec554a09d.zip
refactored so that the renderer is its own class
Diffstat (limited to 'src/game.h')
-rw-r--r--src/game.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/game.h b/src/game.h new file mode 100644 index 0000000..1142efb --- /dev/null +++ b/src/game.h
@@ -0,0 +1,104 @@
1#ifndef GAME_H_7D2B65AE
2#define GAME_H_7D2B65AE
3
4#include <tuple>
5#include <set>
6#include <random>
7#include <list>
8#include "map.h"
9
10const int GAME_WIDTH = 640*2;
11const int GAME_HEIGHT = 480*2;
12const int TILE_WIDTH = 8*2;
13const int TILE_HEIGHT = TILE_WIDTH;
14const int INIT_ZOOM = 10;
15const int ZOOM_X_FACTOR = 8;
16const int ZOOM_Y_FACTOR = 6;
17const int RADIUS = 8;
18
19enum class Tile {
20 Floor,
21 Wall,
22 Dust,
23 Lamp
24};
25
26enum class Source {
27 None,
28 Dust,
29 Lamp,
30 Player
31};
32
33enum class LoseState {
34 None,
35 PoppingLamps,
36 PoppingPlayer,
37 Outro
38};
39
40struct Input {
41 bool left = false;
42 bool right = false;
43 bool up = false;
44 bool down = false;
45};
46
47using coord = std::tuple<int, int>;
48
49struct Kickup {
50 int x;
51 int y;
52 size_t cur;
53 size_t radius;
54 size_t chain;
55 std::set<coord> done;
56 std::set<coord> front;
57};
58
59struct MapData {
60 Tile tile = Tile::Floor;
61 bool lit = false;
62 bool wasLit = false;
63 size_t dustLife = 0;
64 Source lightType = Source::None;
65 int lightRadius = 0;
66 std::set<coord> litTiles;
67};
68
69class Game {
70public:
71
72 Game(std::mt19937& rng) :
73 rng(rng),
74 map(
75 -INIT_ZOOM * ZOOM_X_FACTOR / 2,
76 -INIT_ZOOM * ZOOM_Y_FACTOR / 2,
77 INIT_ZOOM * ZOOM_X_FACTOR,
78 INIT_ZOOM * ZOOM_Y_FACTOR)
79 {
80 }
81
82 std::mt19937& rng;
83
84 Map<MapData> map;
85 std::list<Kickup> kickups;
86 int litSpots = 0;
87 bool dirtyLighting = true;
88 size_t numLamps = 0;
89 size_t numDust = 0;
90
91 int player_x = 0;
92 int player_y = 0;
93 bool renderPlayer = true;
94
95 int curZoom = INIT_ZOOM;
96 int maxZoom = INIT_ZOOM;
97
98 bool zooming = false;
99 //size_t oldZoom;
100 int zoomProgress = 0;
101
102};
103
104#endif /* end of include guard: GAME_H_7D2B65AE */