diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index ad8b0b6..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(project_maat) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) - -add_subdirectory(src) -add_subdirectory(tests) - -# Detect and add SFML -find_package(SFML COMPONENTS system window graphics network audio REQUIRED) -if(NOT SFML_FOUND) - message(FATAL_ERROR "SFML could not be found") -endif() - -# Detect and add GTest -find_package(GTest REQUIRED) -if(GTest_FOUND) - enable_testing() -else() - message(FATAL_ERROR "GTest could not be found") -endif() - -# Find PugiXML -find_path(PugiXML_INCLUDE_DIR pugixml.hpp) -if(NOT IS_DIRECTORY ${PugiXML_INCLUDE_DIR}) - message(FATAL_ERROR "PugiXML could not be found") -endif() \ No newline at end of file diff --git a/README.md b/README.md index 576b9e4..4a5b38f 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,14 @@ Project Maat is the codename of my C++ course "mini-project" based on the quote This game is aimed to be a puzzle game in which the player sets different laws for the world and the people within it as to control what happens after hitting "play" and achieve the level's goal. I was inspired both by [The Incredible Machine](https://en.wikipedia.org/wiki/The_Incredible_Machine_(video_game)) and its successors and by a much more recent game : [Baba is you](https://en.wikipedia.org/wiki/Baba_Is_You). -## Structure - -![UML Diagram](UML_Class_Diagram.png) - ## TODO - [ ] Level - - [x] Structure + - [ ] Structure - [ ] Parsing from XML - [ ] A* - [ ] Entities - - [x] Structure + - [ ] Strucutre - [ ] Parsing from XML - [ ] Moving - [ ] Decorators (Rules) diff --git a/UML_Class_Diagram.png b/UML_Class_Diagram.png deleted file mode 100644 index 5f40a3d..0000000 Binary files a/UML_Class_Diagram.png and /dev/null differ diff --git a/resources/test_level.xml b/resources/test_level.xml deleted file mode 100644 index 7b4af30..0000000 --- a/resources/test_level.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index df21f86..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -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 Game.cpp Game.h Utils.h Utils.h) - -target_link_libraries(engine - sfml-window - sfml-graphics - sfml-system) \ No newline at end of file diff --git a/src/Entity.cpp b/src/Entity.cpp deleted file mode 100644 index fd4cfca..0000000 --- a/src/Entity.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Created by trotfunky on 06/06/19. -// - -#include "Entity.h" - -const std::map Entity::entityTypeLookup = { - {"Citizen",EntityType::Citizen}, - {"Player",EntityType::Player}, - {"House",EntityType::House}, - {"Car",EntityType::Car}}; - -Entity::Entity(int x, int y, EntityType type, int width, int height) -{ - -} - -Entity::Entity(const pugi::xml_node& entityNode) -{ - -} - -void Entity::render(sf::RenderWindow& renderWindow) const -{ - -} - -void Entity::move() -{ - -} - -void Entity::update() -{ - -} - -const sf::RectangleShape& Entity::getShape() const -{ - return(shape); -} diff --git a/src/Entity.h b/src/Entity.h deleted file mode 100644 index be52d46..0000000 --- a/src/Entity.h +++ /dev/null @@ -1,69 +0,0 @@ -// -// Created by trotfunky on 06/06/19. -// - -#ifndef SRC_ENTITY_H -#define SRC_ENTITY_H - -#include -#include - -#include "Utils.h" - - -enum class EntityType -{ - Citizen, - Player, - House, - Car, -}; - -enum class State -{ - Moving, - Fleeing, - Waiting, - Idle, -}; - -enum class Orientation -{ - Nort, - East, - South, - West, -}; - - -class Entity -{ -public: - /// x,y, width and height are in grid coordinates - Entity(int x, int y, EntityType type, int width = 1, int height = 1); - Entity(const pugi::xml_node& entityNode); - - void render(sf::RenderWindow& renderWindow) const; - void move(); - void update(); - - const sf::RectangleShape& getShape() const; - - /// Position of the target of the current action on the map - sf::Vector2i target; -private: - static const std::map entityTypeLookup; - - // 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; -}; - - -#endif //SRC_ENTITY_H diff --git a/src/Game.cpp b/src/Game.cpp deleted file mode 100644 index 6983d39..0000000 --- a/src/Game.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include - -// -// Created by trotfunky on 06/06/19. -// - -#include "Game.h" - - -Game::Game(const std::vector& levels, const std::vector& textures) -{ - - - loadTextures(); -} - -void Game::loadLevel(int levelId) -{ - pugi::xml_document document; - pugi::xml_parse_result result = document.load_file(levelFiles.at(levelId).c_str()); - - if(!result) - { - std::cerr << "Error while loading level :\n" << "\t" << result.description() << std::endl; - exit(-1); - } - - currentLevel = std::make_unique(document,textures); -} - -void Game::loadTextures() -{ - textures.reserve(textureFiles.size()); - for(const std::string& filePath : textureFiles) - { - textures.emplace_back(std::make_unique()); - textures.back()->loadFromFile(filePath); - } -} - -void Game::runGame() -{ - -} diff --git a/src/Game.h b/src/Game.h deleted file mode 100644 index da9f7b2..0000000 --- a/src/Game.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// Created by trotfunky on 06/06/19. -// - -#ifndef SRC_GAME_H -#define SRC_GAME_H - -#include -#include -#include - -#include "Level.h" -#include "Entity.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 - /// Closes the program if there is a fatal error (Missing file, bad file...) - void loadLevel(int levelId); - - std::unique_ptr currentLevel; - - // This should not be called before a level has been loaded - void runGame(); - -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.cpp b/src/Level.cpp deleted file mode 100644 index 1c0903b..0000000 --- a/src/Level.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Created by trotfunky on 06/06/19. -// - -#include "Level.h" - - -Level::Level(const pugi::xml_document& xmlDoc, const TextureStore& textureStore) - : textures(textureStore), - size(xmlDoc.child("Level").attribute("width").as_int(),xmlDoc.child("Level").attribute("width").as_int()) -{ - pugi::xml_node levelNode = xmlDoc.child("Level"); - for(const pugi::xml_node& child : levelNode.children()) - { - if(!strncmp(child.name(),"Entity",6)) - { - entities.emplace_back(child); - } - } -} - -void Level::render(sf::RenderWindow& renderWindow) const -{ - -} - -void Level::runStep() const -{ - -} diff --git a/src/Level.h b/src/Level.h deleted file mode 100644 index 63379f9..0000000 --- a/src/Level.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Created by trotfunky on 06/06/19. -// - -#ifndef SRC_LEVEL_H -#define SRC_LEVEL_H - -#include -#include -#include -#include - -#include "Utils.h" -#include "Entity.h" - -using TextureStore = std::vector>; - -class Level { -public: - Level(const pugi::xml_document& xmlDoc, const TextureStore& textureStore); - - void render(sf::RenderWindow& renderWindow) const; - void runStep() const; - -private: - const sf::Vector2i size; - - std::vector entities; - - const TextureStore& textures; -}; - - -#endif //SRC_LEVEL_H diff --git a/src/Utils.h b/src/Utils.h deleted file mode 100644 index 8fa40a5..0000000 --- a/src/Utils.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// Created by trotfunky on 07/06/19. -// - -#ifndef PROJECT_MAAT_UTILS_H -#define PROJECT_MAAT_UTILS_H - -#include - - -namespace pro_maat -{ - -static constexpr uint8_t pixelsPerUnit = 20; - -} - -#endif //PROJECT_MAAT_UTILS_H diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 0924c9a..0000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(project_maat) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) - -add_executable(gTests gTests.cpp gTests.cpp) - -target_link_libraries(gTests - engine - gtest - pthread) \ No newline at end of file diff --git a/tests/gTests.cpp b/tests/gTests.cpp deleted file mode 100644 index 0eccc74..0000000 --- a/tests/gTests.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by Teo-CD on 06/06/19. -// - -#include - -int main(int argc, char** argv) -{ - ::testing::InitGoogleTest(&argc,argv); - return RUN_ALL_TESTS(); -} \ No newline at end of file