diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-16 21:49:15 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-16 21:49:15 +0100 |
commit | 58c57578cae755422c35acfbbdf9ad399b4fd826 (patch) | |
tree | f8d5cb8a594a2dd247f5c71a8681c6e48389d272 /src/example | |
parent | 9f3af4431853288c6e1ec0ff5b8f5bb0e6379b66 (diff) |
very illegal commit do not push
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/example/FontExample.cpp | 51 | ||||
-rw-r--r-- | src/example/loadfont.cpp | 2 |
3 files changed, 53 insertions, 1 deletions
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 0e2d5e2..f62414e 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -20,4 +20,5 @@ add_example(rendering_particle) add_example(game) add_example(button) add_example(loadfont) +add_example(FontExample) add_example(AITest) diff --git a/src/example/FontExample.cpp b/src/example/FontExample.cpp new file mode 100644 index 0000000..620cf8e --- /dev/null +++ b/src/example/FontExample.cpp @@ -0,0 +1,51 @@ +#include <crepe/api/Text.h> +#include <SDL2/SDL_ttf.h> +#include <crepe/facade/Font.h> +#include <crepe/facade/SDLContext.h> +#include <crepe/manager/Mediator.h> +#include <crepe/manager/ResourceManager.h> +#include <crepe/manager/EventManager.h> +#include <crepe/api/Scene.h> +#include <crepe/api/Script.h> +#include <crepe/api/GameObject.h> +#include <exception> +#include <iostream> +#include <memory> +#include <chrono> +using namespace crepe; +using namespace std; +using namespace std::chrono; +class TestScript : public Script{ + public: + steady_clock::time_point start_time; + virtual void init() override{ + start_time = steady_clock::now(); + } + virtual void update() override{ + auto now = steady_clock::now(); + auto elapsed = duration_cast<seconds>(now - start_time).count(); + + if (elapsed >= 1) { + Mediator& med = mediator; + EventManager& event_mgr = med.event_manager; + event_mgr.trigger_event<ShutDownEvent>(); + } + } +}; +class TestScene : public Scene{ + public: + void load_scene() override{ + GameObject text_object = this->new_object("test","test",vec2{0,0},0,1); + text_object.add_component<Text>(vec2(100, 100), vec2(0, 0), "test test", + "OpenSymbol", Text::Data{}); + text_object.add_component<BehaviorScript>(); + + } + std::string get_name(){ return "hey";} +}; +int main() { + + + + return 0; +} diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp index a77e457..f863053 100644 --- a/src/example/loadfont.cpp +++ b/src/example/loadfont.cpp @@ -13,7 +13,7 @@ int main() { // SDLFontContext font_facade; Mediator mediator; SDLContext sdl_context{mediator}; - ComponentManager component_manager{mediator}; + // ComponentManager component_manager{mediator}; ResourceManager resource_manager{mediator}; try { // Correct way to create a unique pointer for Text |