diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-19 20:49:09 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-19 20:49:09 +0100 |
commit | 0f9f379a4dec7ad9d1dce30af5e2259931692c5f (patch) | |
tree | d84a76559d99fd6a3541d0087538564d79e39470 /src/example/script.cpp | |
parent | 38a2476bcfa41b6d83a9a72d35f5acb684dc87fd (diff) | |
parent | 0476a8e9dbe7afb422862f7b1c15aaed7f3c416e (diff) |
merge with master
Diffstat (limited to 'src/example/script.cpp')
-rw-r--r-- | src/example/script.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/example/script.cpp b/src/example/script.cpp index 9e8b147..a23295b 100644 --- a/src/example/script.cpp +++ b/src/example/script.cpp @@ -5,7 +5,7 @@ #include <crepe/ComponentManager.h> #include <crepe/system/ScriptSystem.h> -#include <crepe/util/log.h> +#include <crepe/util/Log.h> #include <crepe/api/BehaviorScript.h> #include <crepe/api/Config.h> @@ -20,7 +20,7 @@ using namespace std; int _ = []() { // Show dbg_trace() output auto & cfg = Config::get_instance(); - cfg.log.level = LogLevel::TRACE; + cfg.log.level = Log::Level::TRACE; return 0; // satisfy compiler }(); @@ -30,20 +30,20 @@ class MyScript : public Script { void update() { // Retrieve component from the same GameObject this script is on Transform & test = get_component<Transform>(); - dbg_logf("Transform(%.2f, %.2f)", test.position.x, test.position.y); + dbg_logf("Transform({:.2f}, {:.2f})", test.position.x, test.position.y); } }; int main() { + ComponentManager component_manager{}; + ScriptSystem system{component_manager}; + // Create game object with Transform and BehaviorScript components - auto obj = GameObject(0, "name", "tag", Vector2{1.2, 3.4}, 0, 1); + GameObject obj = component_manager.new_object("name"); obj.add_component<BehaviorScript>().set_script<MyScript>(); - // Get ScriptSystem singleton instance (this would normally be done from the - // game loop) - ScriptSystem sys; // Update all scripts. This should result in MyScript::update being called - sys.update(); + system.update(); return EXIT_SUCCESS; } |