diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e61928..ad8b0b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.14) -project(src) +project(project_maat) set(CMAKE_CXX_STANDARD 17) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) diff --git a/README.md b/README.md index 7d4ca64..576b9e4 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ This game is aimed to be a puzzle game in which the player sets different laws f ## TODO - [ ] Level - - [ ] Structure + - [x] Structure - [ ] Parsing from XML - [ ] A* - [ ] Entities - - [ ] Strucutre + - [x] Structure - [ ] Parsing from XML - [ ] Moving - [ ] Decorators (Rules) diff --git a/UML_Class_Diagram.png b/UML_Class_Diagram.png index c9f4d91..bb6dacb 100644 Binary files a/UML_Class_Diagram.png and b/UML_Class_Diagram.png differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df9624a..671a0a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.14) -project(src) +project(project_maat) set(CMAKE_CXX_STANDARD 17) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) -add_library(engine Level.cpp Level.h Entity.cpp Entity.h) +add_library(engine Level.cpp Level.h Entity.cpp Entity.h Game.cpp Game.h) target_link_libraries(engine sfml-window diff --git a/src/Entity.h b/src/Entity.h index d89911c..b79c1b3 100644 --- a/src/Entity.h +++ b/src/Entity.h @@ -5,9 +5,55 @@ #ifndef SRC_ENTITY_H #define SRC_ENTITY_H +#include -class Entity { +enum class EntityType +{ + Citizen, + Player, + House, + Car, +}; + +enum class State +{ + Moving, + Fleeing, + Waiting, + Idle, +}; + +enum class Orientation +{ + Nort, + East, + South, + West, +}; + + +class Entity +{ +public: + Entity(); + + void render(sf::RenderWindow& renderWindow) const; + void move(); + void update(); + + /// Position of the target of the current action on the map + sf::Vector2i target; +private: + // As it contains position, size and orientation, we do not need anything more + sf::RectangleShape shape; + + State currentState; + /// Used with rules : last to update has priority + State nextState; + + /// Used with rules : last to update has priority + sf::Vector2i nextTarget; }; diff --git a/src/Game.cpp b/src/Game.cpp new file mode 100644 index 0000000..8428f60 --- /dev/null +++ b/src/Game.cpp @@ -0,0 +1,6 @@ +// +// Created by trotfunky on 06/06/19. +// + +#include "Game.h" + diff --git a/src/Game.h b/src/Game.h new file mode 100644 index 0000000..7dbc0f6 --- /dev/null +++ b/src/Game.h @@ -0,0 +1,38 @@ +// +// Created by trotfunky on 06/06/19. +// + +#ifndef SRC_GAME_H +#define SRC_GAME_H + +#include +#include + +#include "Level.h" + + +// Used for convenience +using TextureStore = std::vector>; + +class Game { +public: + Game(const std::vector& levels, const std::vector& textures); + + /// Loads the level of corresponding ID from Game::levelFiles + void loadLevel(int levelId); + + Level currentLevel; + +private: + /// Store the paths to level files + const std::vector levelFiles; + /// Store the paths to texture files + const std::vector textureFiles; + /// Stores pointers to textures for future use + TextureStore textures; + + void loadTextures(); +}; + + +#endif //SRC_GAME_H diff --git a/src/Level.h b/src/Level.h index a3f959b..a2a03be 100644 --- a/src/Level.h +++ b/src/Level.h @@ -5,13 +5,26 @@ #ifndef SRC_LEVEL_H #define SRC_LEVEL_H +#include +#include + +#include "Entity.h" +#include "Game.h" + class Level { - Level(); +public: + Level(const TextureStore& textureStore); + + void render(sf::RenderWindow& renderWindow) const; + void runStep() const; private: - int width; - int height; + const sf::Vector2i size; + + std::vector entities; + + const TextureStore& textures; }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0d53663..0924c9a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.14) -project(src) +project(project_maat) set(CMAKE_CXX_STANDARD 17) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})