diff options
Diffstat (limited to 'src/main/headers')
-rw-r--r-- | src/main/headers/Actor.hpp | 40 | ||||
-rw-r--r-- | src/main/headers/Map.hpp | 25 | ||||
-rw-r--r-- | src/main/headers/Scene.hpp | 12 | ||||
-rw-r--r-- | src/main/headers/Subconscious.hpp | 33 | ||||
-rw-r--r-- | src/main/headers/Tile.hpp | 17 | ||||
-rw-r--r-- | src/main/headers/WorldScene.hpp | 33 |
6 files changed, 160 insertions, 0 deletions
diff --git a/src/main/headers/Actor.hpp b/src/main/headers/Actor.hpp new file mode 100644 index 0000000..7cc3be5 --- /dev/null +++ b/src/main/headers/Actor.hpp @@ -0,0 +1,40 @@ +#ifndef ACTOR_HPP +#define ACTOR_HPP + +#include <string> + +class Actor +{ +public: + const enum Type + { + PLAYER, ENEMY + } type; + + const unsigned maxHp; + const std::string name; + + Actor() = delete; + Actor(std::string _name, unsigned _maxHp, Type _type); + virtual ~Actor(); + + void damage(int amt); + void heal(int amt); + + // TODO shouldnt be done by the map ? + // bool move(int x, y); + + /* accessors */ + bool alive() { return _alive; } + unsigned hp() { return _hp; } + + int x() { return _x; } + int y() { return _y; } + +private: + bool _alive; + unsigned _hp; + int _x, _y; +}; + +#endif diff --git a/src/main/headers/Map.hpp b/src/main/headers/Map.hpp new file mode 100644 index 0000000..81c456e --- /dev/null +++ b/src/main/headers/Map.hpp @@ -0,0 +1,25 @@ +#ifndef MAP_HPP +#define MAP_HPP + +#include "Tile.hpp" + +#include <vector> + +class Map +{ +public: + const unsigned width; + const unsigned height; + + Map(); + + Tile& tile(unsigned x, unsigned y); + const std::vector<Tile>& tiles() const; + + bool moveActor(Tile &from, Tile &to); + +private: + std::vector<Tile> _tiles; +}; + +#endif diff --git a/src/main/headers/Scene.hpp b/src/main/headers/Scene.hpp new file mode 100644 index 0000000..2b19d31 --- /dev/null +++ b/src/main/headers/Scene.hpp @@ -0,0 +1,12 @@ +#ifndef SCENE_HPP +#define SCENE_HPP + +#include <SFML/Graphics.hpp> + +class Scene +{ +public: + virtual void render(sf::RenderWindow &window) = 0; +}; + +#endif diff --git a/src/main/headers/Subconscious.hpp b/src/main/headers/Subconscious.hpp new file mode 100644 index 0000000..8713757 --- /dev/null +++ b/src/main/headers/Subconscious.hpp @@ -0,0 +1,33 @@ +#ifndef SUBCONSCIOUS_HPP +#define SUBCONSCIOUS_HPP + +#include "Scene.hpp" + +#include <SFML/Graphics.hpp> +#include <vector> + +class Subconscious +{ +public: + Subconscious(); + ~Subconscious(); + + void run(); + void demo(); + +private: + // game + bool _running = false; + bool _gameOver = false; + + // graphics + sf::RenderWindow _window; + + std::vector<Scene *> _scenes; + Scene *_currentScene = nullptr; + + void gameUpdate(); + void gameRender(); +}; + +#endif diff --git a/src/main/headers/Tile.hpp b/src/main/headers/Tile.hpp new file mode 100644 index 0000000..7292fde --- /dev/null +++ b/src/main/headers/Tile.hpp @@ -0,0 +1,17 @@ +#ifndef TILE_HPP +#define TILE_HPP + +struct Tile +{ + enum Type + { + GRASS, WATER + }; + + const Type type; + const int x, y; + + Tile(Type _type, int _x, int _y) : type(_type), x(_x), y(_y) {} +}; + +#endif diff --git a/src/main/headers/WorldScene.hpp b/src/main/headers/WorldScene.hpp new file mode 100644 index 0000000..acdda63 --- /dev/null +++ b/src/main/headers/WorldScene.hpp @@ -0,0 +1,33 @@ +#ifndef WORLDSCENE_HPP +#define WORLDSCENE_HPP + +#include "Scene.hpp" +#include "Map.hpp" + +#include <SFML/Graphics.hpp> + + +class WorldScene : public Scene +{ +public: + constexpr static int ZOOM_MIN = 1; + constexpr static int ZOOM_MAX = 100; + constexpr static int DEFAULT_TILE_SIZE_PX = 20; + + WorldScene(); + + virtual void render(sf::RenderWindow &window); + + virtual void zoom(int value); + virtual void pan(int dx, int dy); + +private: + Map map; + + unsigned _tileSize; + + int _panX = 0; + int _panY = 0; +}; + +#endif |