From a764ef0f1f6b7c5d18155163d63db1a6dd47093a Mon Sep 17 00:00:00 2001 From: Max-001 Date: Tue, 24 Dec 2024 14:38:01 +0100 Subject: Added end script --- game/EndGameScript.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++------- game/EndGameScript.h | 3 +++ 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/game/EndGameScript.cpp b/game/EndGameScript.cpp index 55f08cd..a18f18c 100644 --- a/game/EndGameScript.cpp +++ b/game/EndGameScript.cpp @@ -1,5 +1,8 @@ #include "EndGameScript.h" +#include +#include +#include #include #include @@ -7,14 +10,51 @@ using namespace crepe; using namespace std; void EndGameScript::init() { - Rigidbody & rb_player = this->get_components_by_name("player").front(); - Rigidbody & rb_camera = this->get_components_by_name("camera").front(); - - rb_player.data.linear_velocity_coefficient = vec2(0.8, 0.8); - rb_camera.data.linear_velocity_coefficient = vec2(0.8, 0.8); + BoxCollider jetpack_coll = this->get_components_by_name("player").back(); + CircleCollider head_coll = this->get_components_by_name("player").back(); + jetpack_coll.active = false; + head_coll.active = false; } void EndGameScript::fixed_update(crepe::duration_t dt) { - //logf("EndGameScript::fixed_update"); - // ... + Transform & transform_player = this->get_components_by_name("player").front(); + RefVector anim_player = this->get_components_by_name("player"); + Rigidbody & rb_player = this->get_components_by_name("player").front(); + Rigidbody & rb_camera = this->get_components_by_name("camera").front(); + + if (transform_player.position.y >= 194) { + if (jump == 0 || jump == 1) { + int random_number = rand() % 4; + for (Animator & anim : anim_player) { + anim.active = false; + anim.set_anim(6); + for (int i = 0; i < random_number; i++) { + anim.next_anim(); + } + } + } else if (jump == 2) { + for (Animator & anim : anim_player) { + anim.active = false; + anim.set_anim(7); + } + rb_player.data.angular_velocity = 0; + transform_player.rotation = 90; + } + if (jump == 0) { + rb_player.data.linear_velocity = vec2(100, -150); + rb_player.data.angular_velocity = 320; + rb_player.data.angular_velocity_coefficient = 0.8; + jump++; + } else if (jump == 1) { + rb_player.data.linear_velocity = vec2(100, -125); + rb_player.data.angular_velocity = 300; + rb_player.data.angular_velocity_coefficient = 0.8; + jump++; + } else if (jump == 2) { + rb_player.data.linear_velocity = vec2(100, 0); + rb_player.data.linear_velocity_coefficient = vec2(0.5, 0.5); + rb_camera.data.linear_velocity_coefficient = vec2(0.5, 0.5); + jump++; + } + } } diff --git a/game/EndGameScript.h b/game/EndGameScript.h index 3b1970a..980dff5 100644 --- a/game/EndGameScript.h +++ b/game/EndGameScript.h @@ -6,4 +6,7 @@ class EndGameScript : public crepe::Script { public: void init(); void fixed_update(crepe::duration_t dt); + +private: + int jump = 0; }; -- cgit v1.2.3