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 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include/game.hpp') 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 -- cgit