diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9c7a2f51a16c2e0930d1da2b5a26a356b2b4665..bf72a0c7ffed13b8b697dc5d1ff3ab3fb1b647ae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,34 +1,22 @@ -# This file is a template, and might need editing before it works on your project. -# To contribute improvements to CI/CD templates, please follow the Development guide at: -# https://docs.gitlab.com/ee/development/cicd/templates.html -# This specific template is located at: -# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/C++.gitlab-ci.yml - -# use the official gcc image, based on debian -# can use versions as well, like gcc:5.2 -# see https://hub.docker.com/_/gcc/ - image: gcc build: stage: build - # instead of calling g++ directly you can also use some build toolkit like make - # install the necessary build tools when needed before_script: - mkdir bin - mkdir saves + - mkdir logs script: - make console artifacts: paths: - bin/ - # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time - # cache: - # paths: - # - "*.o" + cache: + paths: + - "build/*.o" # run tests using the binary built before test: stage: test script: - - echo "Dummy Testing" + - make test diff --git a/include/asset.h b/include/asset.h index a2e1cd798d41dfef6da571748b0f202dbeb8a32c..abf0a6a5b29572750defa38b3b6a6d14973e6e6f 100644 --- a/include/asset.h +++ b/include/asset.h @@ -1,6 +1,8 @@ #ifndef __ASSET_H__ #define __ASSET_H__ +#include <string> + #include "logger.h" class Asset @@ -8,6 +10,8 @@ class Asset public: Asset(); ~Asset(); + + void loadMedia( std::string path ); private: Logger& _logger; }; diff --git a/include/game-engine.h b/include/game-engine.h index 1b376bbb0fbfd3f5954ce3980cd7dc08c489742a..e3d7fbcef96cfe5c760ad8aef471f9c172ba2039 100644 --- a/include/game-engine.h +++ b/include/game-engine.h @@ -1,6 +1,7 @@ #ifndef __GAME_H__ #define __GAME_H__ +#include <memory> #include <map> #include <string> #include <vector> @@ -12,10 +13,14 @@ #include "logger.h" #include "entity-manager.h" #include "scene.h" +#include "asset.h" +// #include "window.h" #ifdef console #endif +class Window {}; + class GameEngine { public: @@ -26,11 +31,11 @@ class GameEngine void update(); void close(); Scene* currentScene(); - // void changeScene( Scene scene ); - // std::vector< Asset& > getAssets(); - // Window& getWindow(); + void changeScene( std::string label, Scene *scene ); + void changeScene( std::string label ); + std::vector< Asset& > getAssets(); + Window& getWindow(); - std::vector<Asset> getAssets(); void sUserInput(); bool isRunning; @@ -41,11 +46,12 @@ class GameEngine EntityManager _entityManager; Logger& _logger; - std::string _currScene; - // Window* _window; - // std::vector<Asset> _assets; - // std::map< std::string, Scene > _scenes; + Window* _window; + std::vector<Asset> _assets; /** @todo : move this to scene */ + + std::string _currScene; + std::map< std::string, Scene* > _scenes; /* Systems */ // sUserInput diff --git a/include/scene.h b/include/scene.h index 20d4568005fcb8f4e90efad245077c1c031e2eb8..92ce89aacc30629debeca0420922dde1dc4e06ed 100644 --- a/include/scene.h +++ b/include/scene.h @@ -12,14 +12,15 @@ class Scene{ public: - Scene(); + Scene();// : _logger( Logger::instance() ) {} ~Scene(); virtual void update() = 0; virtual void simulate() = 0; virtual void doAction() = 0; + virtual void render() = 0; virtual void registerAction() = 0; - private: + protected: std::vector<Asset> _assets; Logger& _logger; diff --git a/include/scenes/scene_play.h b/include/scenes/scene_play.h new file mode 100644 index 0000000000000000000000000000000000000000..16483a51230588e5ea21bc6661336d1d111b2419 --- /dev/null +++ b/include/scenes/scene_play.h @@ -0,0 +1,24 @@ +#ifndef __SCENES__PLAY_H__ +#define __SCENES__PLAY_H__ + +#include "scene.h" +#include "entities/entity.h" + +class ScenePlay : public Scene +{ + public: + void update(); + void simulate(); + void doAction(); + void render(); + void registerAction(); + + private: + std::string _levelPath; + Entity* _player; + + // Systems + // sAnimation(); +}; + +#endif // __SCENES__PLAY_H__ diff --git a/makefile b/makefile index a27274bc5b5a274f047a58610e42a301b50a8e9c..d4a020e53a8d3edc211917aa565a66dda0b1dc6b 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,7 @@ +VERSION_MAJOR = 0 +VERSION_MINOR = 0 +VERSION_PATCH = 0 + ifeq ($(OS),Windows_NT) CXX = g++ # or your Windows compiler CXXFLAGS = -std=c++17 -Wall -Wreorder @@ -72,8 +76,8 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp ${INC_DIR}/*.h clean: rm -rf $(BIN_DIR)/* $(BUILD_DIR)/* test_runnr - rm -rf ./*~ ./*.swp - rm -rf *~ + rm -r ./*~ + rm -r $(SRC_DIR)/*~ ${INC_DIR}/*~ run_tests: $(TEST_OBJ_FILES) $(CXX) $(CXXFLAGS) $(LDFLAGS) $(INC_DIRS) -o ${TEST_TARGET} $^ diff --git a/src/asset.cpp b/src/asset.cpp index b3b506fbf9964135bf6426579e2d5b7b9ac53510..ab192b5a952c9ba517164fec5636fe285c2ff65a 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -4,3 +4,5 @@ Asset::Asset() : _logger( Logger::instance() ) { this->_logger.info( "New asset created" ); } Asset::~Asset(){} + +void Asset::loadMedia( std::string path ) {} diff --git a/src/chunk.cpp b/src/chunk.cpp index ec60f2ea3da6b7e9b653262b65833e8e9aaa628d..33f8a13d4e85711b127759928635fcba526082c9 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -2,11 +2,9 @@ Chunk::Chunk( int x, int y, int z ) - : _x(x), _y(y), _z(z), - _logger( Logger::instance() ) -{ - this->generate(); -} + : _logger( Logger::instance() ), + _x(x), _y(y), _z(z) +{ this->generate(); } Chunk::~Chunk() { // this->_logger.info( "Deleting Chunk" ); diff --git a/src/entities/entity.cpp b/src/entities/entity.cpp index 2c0f0e9ae7ce7a712484b9424718d0e35016ace5..b493de0cdc69fc8d09f98d37606d4939f9520ee5 100644 --- a/src/entities/entity.cpp +++ b/src/entities/entity.cpp @@ -2,7 +2,7 @@ Entity::Entity( const std::string& tag, size_t id -) : _tag( tag ), _id( id ), - _logger( Logger::instance() ) +) : _logger( Logger::instance() ), + _id(id), _tag( tag ) { this->_logger.info( "Generic Entity Created" ); } Entity::~Entity(){} diff --git a/src/game-engine.cpp b/src/game-engine.cpp index 1219df914f6c2cbc16e66c82660a059bc0b73a8c..8c51eb8982282f5fc4389efb918ad8da3721349e 100644 --- a/src/game-engine.cpp +++ b/src/game-engine.cpp @@ -16,11 +16,17 @@ void GameEngine::init() this->isRunning = false; this->_currScene = ""; } -// void GameEngine::changeScene( Scene scene ){} -Scene* GameEngine::currentScene() +void GameEngine::changeScene( std::string label, Scene* scene ) { - return nullptr; + this->_scenes[ label ] = scene; + this->_currScene = label; } +void GameEngine::changeScene( std::string label ) + { this->_currScene = label; } + +Scene* GameEngine::currentScene() + { return this->_scenes[this->_currScene]; } + void GameEngine::run() { this->isRunning = true; @@ -38,9 +44,9 @@ void GameEngine::update() if( ++this->_frame > 10000 ) { this->close(); } else if ( this->_frame % 1000 == 0 ) { std::time_t cTime = std::chrono::system_clock::to_time_t(now); - size_t delTime = cTime - this->_frametime; + // size_t delTime = cTime - this->_frametime; this->_frametime = cTime; - printf( "Frame: %i at %.2f fps\n", this->_frame / 1000, delTime == 0 ? 0.0 : 1.0 / delTime ); + // printf( "Frame: %i at %.2f fps\n", this->_frame / 1000, delTime == 0 ? 0.0 : 1.0 / delTime ); } } void GameEngine::handleInput() { } diff --git a/src/scenes/scene_play.cpp b/src/scenes/scene_play.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9572ee8ace3b5873e10084145691e0e441ca9aff --- /dev/null +++ b/src/scenes/scene_play.cpp @@ -0,0 +1,7 @@ +#include "scenes/scene_play.h" + +void ScenePlay::update(){} +void ScenePlay::simulate(){} +void ScenePlay::doAction(){} +void ScenePlay::render(){} +void ScenePlay::registerAction(){} diff --git a/src/world-hex-2d.cpp b/src/world-hex-2d.cpp index 2e7ced3105c2cbb718b041b3d33db8fbb71b9989..6892f4edf2920a9c540558d826a2a696ef9b7336 100644 --- a/src/world-hex-2d.cpp +++ b/src/world-hex-2d.cpp @@ -8,8 +8,8 @@ WorldHex2D::WorldHex2D( uint8_t radius ) ) {} WorldHex2D::WorldHex2D( uint8_t width, uint8_t height, uint8_t depth) - : _width( width ), _height( height ), _depth( depth ), - _logger( Logger::instance() ) + : _logger( Logger::instance() ), + _width( width ), _height( height ), _depth( depth ) { this->_logger.info( "Creating Hex Map" ); this->generateWorld(); diff --git a/src/world-map3d.cpp b/src/world-map3d.cpp index c34b95ae6b9ae95bcac7c27dbb16e49c509bc9d9..010bef087703dfa7f5dcadc61bb70fbff60442de 100644 --- a/src/world-map3d.cpp +++ b/src/world-map3d.cpp @@ -7,8 +7,9 @@ WorldMap3D::WorldMap3D( uint8_t width, uint8_t height, uint8_t depth -) : _width(width), _height(height), _depth(depth), - _logger( Logger::instance() ) +) : + _logger( Logger::instance() ), + _width(width), _height(height), _depth(depth) { this->_logger.info( "Creating new world" ); this->generateWorld();