aboutsummaryrefslogtreecommitdiff
path: root/game/menus/ButtonReplaySubScript.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2025-01-08 12:59:26 +0100
committerJAROWMR <jarorutjes07@gmail.com>2025-01-08 12:59:26 +0100
commitf6d1aa2fe104323b17ef3ed56e33651c67b3febe (patch)
tree8f097216fd166239eb71914e6b98ac0285171d5b /game/menus/ButtonReplaySubScript.cpp
parentc9c9702edc58ff8f40b13dc6b86b216421f79e9b (diff)
added replay functionality
Diffstat (limited to 'game/menus/ButtonReplaySubScript.cpp')
-rw-r--r--game/menus/ButtonReplaySubScript.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/game/menus/ButtonReplaySubScript.cpp b/game/menus/ButtonReplaySubScript.cpp
new file mode 100644
index 0000000..26cb8ee
--- /dev/null
+++ b/game/menus/ButtonReplaySubScript.cpp
@@ -0,0 +1,31 @@
+#include "ButtonReplaySubScript.h"
+#include "MenusConfig.h"
+
+#include <crepe/api/AudioSource.h>
+#include <crepe/types.h>
+#include "../Events.h"
+
+using namespace crepe;
+using namespace std;
+
+void ButtonReplaySubScript::init() {
+ IButtonScript::init();
+ this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent & e) {
+ return this->on_button_press(e);
+ });
+ this->subscribe<EndGameEvent>([this](const EndGameEvent & e) {
+ return this->set_recording();
+ });
+ replay.record_start();
+}
+
+
+bool ButtonReplaySubScript::on_button_press(const ButtonPressEvent & e) {
+ replay.play(this->recording);
+ return false;
+}
+
+bool ButtonReplaySubScript::set_recording(){
+ this->recording = replay.record_end();
+ return false;
+}