aboutsummaryrefslogtreecommitdiff
path: root/game/mainmenu/ShowScript.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-23 21:17:45 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-23 21:17:45 +0100
commit225e873c8ac9c4c08720a69b8f2c817d22cf0071 (patch)
tree20c1539a7ea7d133fca143e922165fd7533c87fe /game/mainmenu/ShowScript.cpp
parenta3097a20daaf58e4e3852bfb36315dc5e14d3e52 (diff)
made script reusable to switch scenes
Diffstat (limited to 'game/mainmenu/ShowScript.cpp')
-rw-r--r--game/mainmenu/ShowScript.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/game/mainmenu/ShowScript.cpp b/game/mainmenu/ShowScript.cpp
new file mode 100644
index 0000000..dbd638e
--- /dev/null
+++ b/game/mainmenu/ShowScript.cpp
@@ -0,0 +1,26 @@
+#include "ShowScript.h"
+#include "api/Rigidbody.h"
+#include "api/Transform.h"
+#include "iostream"
+#include <crepe/api/Camera.h>
+#include "MainMenuConfig.h"
+
+using namespace crepe;
+using namespace std;
+
+void ShowScript::frame_update(crepe::duration_t delta_time){
+ if(this->transition)
+ {
+ cout << "transition:" << velocity << std::endl;
+ Transform & cam = this->get_components_by_name<Transform>(MainMenuConfig::CAMERA_NAME).front();
+ if(velocity < MainMenuConfig::VELOCITY_MAX && cam.position.x < MainMenuConfig::SLOW_DOWN) velocity += MainMenuConfig::VELOCITY_STEP * delta_time.count();
+ else if(velocity > 20) velocity -= MainMenuConfig::VELOCITY_STEP * delta_time.count();
+ if(cam.position.x < MainMenuConfig::END) cam.position.x += (velocity * delta_time.count());
+ if(cam.position.x >= MainMenuConfig::END)
+ {
+ this->set_next_scene(this->get_scene_name());
+ }
+
+ }
+}
+