aboutsummaryrefslogtreecommitdiff
path: root/src/example/script.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:08:36 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:08:36 +0100
commit20fc8401083e23e414feae2a9a4d217b228b8f15 (patch)
tree08c9e9c4ddcde5438eb54f6b051895c0896f935b /src/example/script.cpp
parent60669b60e63532bc264ecd6d106bd15f0688a5b6 (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge remote-tracking branch 'origin/master' into niels/rendering_color
Diffstat (limited to 'src/example/script.cpp')
-rw-r--r--src/example/script.cpp16
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;
}