diff options
Diffstat (limited to 'src/game.h')
| -rw-r--r-- | src/game.h | 104 |
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 | |||
| 10 | const int GAME_WIDTH = 640*2; | ||
| 11 | const int GAME_HEIGHT = 480*2; | ||
| 12 | const int TILE_WIDTH = 8*2; | ||
| 13 | const int TILE_HEIGHT = TILE_WIDTH; | ||
| 14 | const int INIT_ZOOM = 10; | ||
| 15 | const int ZOOM_X_FACTOR = 8; | ||
| 16 | const int ZOOM_Y_FACTOR = 6; | ||
| 17 | const int RADIUS = 8; | ||
| 18 | |||
| 19 | enum class Tile { | ||
| 20 | Floor, | ||
| 21 | Wall, | ||
| 22 | Dust, | ||
| 23 | Lamp | ||
| 24 | }; | ||
| 25 | |||
| 26 | enum class Source { | ||
| 27 | None, | ||
| 28 | Dust, | ||
| 29 | Lamp, | ||
| 30 | Player | ||
| 31 | }; | ||
| 32 | |||
| 33 | enum class LoseState { | ||
| 34 | None, | ||
| 35 | PoppingLamps, | ||
| 36 | PoppingPlayer, | ||
| 37 | Outro | ||
| 38 | }; | ||
| 39 | |||
| 40 | struct Input { | ||
| 41 | bool left = false; | ||
| 42 | bool right = false; | ||
| 43 | bool up = false; | ||
| 44 | bool down = false; | ||
| 45 | }; | ||
| 46 | |||
| 47 | using coord = std::tuple<int, int>; | ||
| 48 | |||
| 49 | struct 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 | |||
| 59 | struct 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 | |||
| 69 | class Game { | ||
| 70 | public: | ||
| 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 */ | ||
