From 225e873c8ac9c4c08720a69b8f2c817d22cf0071 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Mon, 23 Dec 2024 21:17:45 +0100 Subject: made script reusable to switch scenes --- game/mainmenu/ButtonStartScript.cpp | 48 ------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 game/mainmenu/ButtonStartScript.cpp (limited to 'game/mainmenu/ButtonStartScript.cpp') diff --git a/game/mainmenu/ButtonStartScript.cpp b/game/mainmenu/ButtonStartScript.cpp deleted file mode 100644 index 8f76802..0000000 --- a/game/mainmenu/ButtonStartScript.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "ButtonStartScript.h" -#include "api/Rigidbody.h" -#include "api/Transform.h" -#include "iostream" -#include -#include "MainMenuConfig.h" - -using namespace crepe; -using namespace std; - -void ButtonStartScript::init(){ - cout << "script init" << endl; - this->subscribe([this](const ButtonPressEvent& e) { return this->on_button_press(e); }); - this->subscribe([this](const ButtonEnterEvent& e) { return this->on_button_enter(e); }); - this->subscribe([this](const ButtonExitEvent& e) { return this->on_button_exit(e); }); -} - -void ButtonStartScript::frame_update(crepe::duration_t delta_time){ - if(this->transition) - { - cout << "transition:" << velocity << std::endl; - Transform & cam = this->get_components_by_name(MainMenuConfig::CAMERA_NAME).front(); - if(velocity < velocity_max && cam.position.x < SLOW_DOWN) velocity += velocity_step * delta_time.count(); - else if(velocity > 20) velocity -= velocity_step * delta_time.count(); - if(cam.position.x < END) cam.position.x += (velocity * delta_time.count()); - if(cam.position.x >= END) - { - this->set_next_scene(MainMenuConfig::START_SCENE); - } - - } -} - -bool ButtonStartScript::on_button_press(const ButtonPressEvent& e){ - this->transition = true; - cout << "Start triggered:" << e.metadata.game_object_id << std::endl; - return false; -} -bool ButtonStartScript::on_button_enter(const ButtonEnterEvent& e){ - - cout << "Start Enter:" << e.metadata.game_object_id << std::endl; - return false; -} -bool ButtonStartScript::on_button_exit(const ButtonExitEvent& e){ - - cout << "Start Exit:" << e.metadata.game_object_id << std::endl; - return false; -} -- cgit v1.2.3