aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-03-21 14:52:18 +0100
committerCharles <sircharlesaze@gmail.com>2020-03-21 14:52:18 +0100
commit0cebd4ae751e0554f948389654fe4ad7e92943f0 (patch)
tree462aecb04faebfda04a56c93c820a32df6cdac23 /include
parentad8ae988ba1928af5063ca1dc7375356e467979b (diff)
downloadmario_sokoban-0cebd4ae751e0554f948389654fe4ad7e92943f0.tar.gz
mario_sokoban-0cebd4ae751e0554f948389654fe4ad7e92943f0.tar.bz2
mario_sokoban-0cebd4ae751e0554f948389654fe4ad7e92943f0.zip
Game logic finished (moving player, crates, checking win)
Diffstat (limited to 'include')
-rw-r--r--include/game.hpp15
-rw-r--r--include/graphics.hpp1
2 files changed, 15 insertions, 1 deletions
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 <string>
+#include <vector>
#include <algorithm>
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<Position> m_cratePos;
+ std::vector<Position> 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;