From 016d1cdf036039792f50e1ed0431386c7b9e93d7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 13 Mar 2022 13:21:17 -0400 Subject: refactored game code into the game class (for titles / multiple games) --- src/game.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'src/game.h') diff --git a/src/game.h b/src/game.h index 9feb774..89b9eb2 100644 --- a/src/game.h +++ b/src/game.h @@ -87,18 +87,15 @@ struct MapData { class Game { public: - Game(std::mt19937& rng) : - rng(rng), - map( - -INIT_ZOOM * ZOOM_X_FACTOR / 2, - -INIT_ZOOM * ZOOM_Y_FACTOR / 2, - INIT_ZOOM * ZOOM_X_FACTOR, - INIT_ZOOM * ZOOM_Y_FACTOR) - { - } + Game(std::mt19937& rng, Muxer& muxer); + + void update(size_t dt); std::mt19937& rng; - Muxer muxer; + Muxer& muxer; + + bool quit = false; + LoseState losing = LoseState::None; Map map; std::list kickups; @@ -129,6 +126,7 @@ public: int lastZoomWidth; int lastZoomHeight; + Input keystate; bool firstInput = false; Input lastInput; bool alreadyBumped = false; @@ -137,6 +135,44 @@ public: bool moving = false; bool queueDash = false; + Timer dustTimer = {40}; + Timer inputTimer = {50}; + Timer losePopLampTimer = {800}; + Timer losePopPlayerTimer = {3000}; + Timer zoomTimer = {62}; + +private: + + void tick( + int x1, + int y1, + int x2, + int y2, + bool invert = false, + bool onlyDark = false); + + void tick(bool onlyDark = false); + + bool movePlayer(int x, int y); + + void recalculateLighting(); + + void recalculateRender(); + + bool processKeys(const Input& keystate); + + void kickUpDust(int x, int y, size_t chain); + + void popLamp(int x, int y, size_t chain); + + void processKickup(); + + void growMap(size_t zoom); + + void setZoom(size_t zoom); + + void performDash(); + }; #endif /* end of include guard: GAME_H_7D2B65AE */ -- cgit 1.4.1