aboutsummaryrefslogtreecommitdiff
path: root/game/hud/SpeedScript.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2025-01-07 14:33:07 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2025-01-07 14:33:07 +0100
commit5d798c30af7026099344a068e91e1684018b4386 (patch)
tree923b54a2745c338478246b8707c6ce8361822fc7 /game/hud/SpeedScript.cpp
parent6d69c8ef6b663bd6716b441cc7d01164c7e33dfc (diff)
parent42cbef630ccaf3e841459d364edade1a3c72a525 (diff)
merge + more WIP
Diffstat (limited to 'game/hud/SpeedScript.cpp')
-rw-r--r--game/hud/SpeedScript.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/game/hud/SpeedScript.cpp b/game/hud/SpeedScript.cpp
new file mode 100644
index 0000000..69534d9
--- /dev/null
+++ b/game/hud/SpeedScript.cpp
@@ -0,0 +1,35 @@
+#include "SpeedScript.h"
+#include "api/Event.h"
+#include "api/KeyCodes.h"
+#include "manager/LoopTimerManager.h"
+
+using namespace crepe;
+using namespace std;
+
+void SpeedScript::init() {
+ this->subscribe<KeyPressEvent>([this](const KeyPressEvent & ev) -> bool {
+ if(ev.key != Keycode::HOME) return false;
+ LoopTimerManager & lp = this->get_loop_timer();
+ this->toggle = !this->toggle;
+ if(this->toggle)
+ {
+ this->timescale = lp.get_time_scale();
+ lp.set_time_scale(0);
+ }
+ else {
+ lp.set_time_scale(this->timescale);
+ }
+
+ return true;
+ });
+}
+
+void SpeedScript::fixed_update(crepe::duration_t dt){
+ LoopTimerManager & lp = this->get_loop_timer();
+ if(this->get_key_state(Keycode::PAGE_UP)){
+ lp.set_time_scale(lp.get_time_scale()+0.1);
+ }
+ if(this->get_key_state(Keycode::PAGE_DOWN)){
+ lp.set_time_scale(lp.get_time_scale()-0.1);
+ }
+}