diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 19:02:40 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-12 19:02:40 +0100 |
commit | 45f1f18c78e73280a8a861df2db6237bae6f6d80 (patch) | |
tree | 78468b25ea85b3582fc4eab296142efd6a0dd92f /src/example/replay.cpp | |
parent | f34daa492c30a0d28b747817a9f2d6fb0186cf80 (diff) |
add script api for replaymanager
Diffstat (limited to 'src/example/replay.cpp')
-rw-r--r-- | src/example/replay.cpp | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/src/example/replay.cpp b/src/example/replay.cpp index e7f4e6d..4c606d7 100644 --- a/src/example/replay.cpp +++ b/src/example/replay.cpp @@ -1,19 +1,6 @@ -#include <crepe/util/OptionalRef.h> -#include <crepe/api/BoxCollider.h> -#include <crepe/api/Camera.h> -#include <crepe/api/Color.h> -#include <crepe/api/Config.h> -#include <crepe/api/Event.h> -#include <crepe/api/GameObject.h> #include <crepe/api/Engine.h> -#include <crepe/api/Rigidbody.h> -#include <crepe/api/Scene.h> #include <crepe/api/Script.h> -#include <crepe/api/Sprite.h> -#include <crepe/api/Transform.h> -#include <crepe/manager/ComponentManager.h> -#include <crepe/manager/Mediator.h> -#include <crepe/manager/ReplayManager.h> +#include <crepe/api/Config.h> using namespace crepe; using namespace std; @@ -34,27 +21,20 @@ class AnimationScript : public Script { class Timeline : public Script { unsigned i = 0; - ReplayManager & mgr; recording_t recording; -public: - Timeline(ReplayManager & mgr) - : mgr(mgr) {} - void update() { switch (i++) { default: break; case 10: - mgr.record_start(); + replay.record_start(); break; case 60: - this->recording = mgr.record_end(); - break; - case 70: - mgr.play(this->recording); + this->recording = replay.record_end(); + replay.play(this->recording); break; - case 71: - mgr.release(this->recording); + case 61: + replay.release(this->recording); break; case 72: throw; @@ -86,7 +66,7 @@ public: square.add_component<BehaviorScript>().set_script<AnimationScript>(); GameObject scapegoat = mgr.new_object(""); - scapegoat.add_component<BehaviorScript>().set_script<Timeline>(mediator.replay_manager); + scapegoat.add_component<BehaviorScript>().set_script<Timeline>(); } string get_name() const { return "scene1"; } @@ -100,5 +80,6 @@ int main(int argc, char * argv[]) { engine.add_scene<TestScene>(); engine.start(); + return 0; } |