From 0cebd4ae751e0554f948389654fe4ad7e92943f0 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 21 Mar 2020 14:52:18 +0100 Subject: Game logic finished (moving player, crates, checking win) --- include/game.hpp | 15 ++++++++++++++- include/graphics.hpp | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/game.hpp b/include/game.hpp index 40ca113..647a12d 100644 --- a/include/game.hpp +++ b/include/game.hpp @@ -2,6 +2,7 @@ # define GAME_HPP #include +#include #include class Game @@ -24,15 +25,18 @@ public: CellWall, CellCrate, CellPayload, + CellCrateSolved }; struct Position { - int y, x; + size_t y, x; }; + bool won(); void move(Direction direction); Cell get(int y, int x) const; + Cell get(Position pos) const; size_t getHeight() const; size_t getWidth() const; Position const &getPlayer() const; @@ -44,6 +48,15 @@ private: Cell **m_grid; Position m_playerPos; Direction m_playerDirection; + std::vector m_cratePos; + std::vector m_payloadPos; + + bool tryMoveCrate(Position &pos, Direction direction); + bool validPosition(Position pos); + static Position makePos(int y, int x); }; +bool operator==(Game::Position const &a, Game::Position const &b); +bool operator!=(Game::Position const &a, Game::Position const &b); + #endif diff --git a/include/graphics.hpp b/include/graphics.hpp index 54f7d35..ea5d70e 100644 --- a/include/graphics.hpp +++ b/include/graphics.hpp @@ -26,6 +26,7 @@ private: SDL_Window *m_window; SDL_Texture *m_wallTex; SDL_Texture *m_crateTex; + SDL_Texture *m_crateSolvedTex; SDL_Texture *m_payloadTex; SDL_Texture *m_playerTex; -- cgit