aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-06 17:39:15 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-06 17:39:15 +0200
commit2969fe8c0fca4826ca129fe12d2e125bb7955c78 (patch)
treeb7514048a8894cc5c64657e817765eb4e860187c /src/example
parent8a509ad4c5e15fbf7eaade1c8bf4834f0d0069c5 (diff)
WIP ScriptSystem
Diffstat (limited to 'src/example')
-rw-r--r--src/example/CMakeLists.txt1
-rw-r--r--src/example/script.cpp33
2 files changed, 34 insertions, 0 deletions
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt
index eef38fd..6df4ce7 100644
--- a/src/example/CMakeLists.txt
+++ b/src/example/CMakeLists.txt
@@ -14,4 +14,5 @@ endfunction()
add_example(audio_internal)
add_example(components_internal)
+add_example(script)
diff --git a/src/example/script.cpp b/src/example/script.cpp
new file mode 100644
index 0000000..28605c7
--- /dev/null
+++ b/src/example/script.cpp
@@ -0,0 +1,33 @@
+/** \file
+ *
+ * Standalone example for usage of the script component and system
+ */
+
+#include <crepe/util/log.h>
+#include <crepe/ScriptSystem.h>
+#include <crepe/ComponentManager.h>
+#include <crepe/GameObject.h>
+
+#include <crepe/api/BehaviorScript.h>
+
+using namespace crepe;
+using namespace std;
+
+class MyScript : public api::BehaviorScript {
+ void update() {
+ dbg_trace();
+ }
+};
+
+int main() {
+ dbg_trace();
+
+ auto obj = GameObject(0, "name", "tag", 0);
+ obj.add_component<MyScript>();
+
+ auto & sys = ScriptSystem::get_instance();
+ sys.update(); // -> MyScript::update
+
+ return 0;
+}
+