aboutsummaryrefslogtreecommitdiff
path: root/game/StartGameScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/StartGameScript.cpp')
-rw-r--r--game/StartGameScript.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/game/StartGameScript.cpp b/game/StartGameScript.cpp
index 50ba86c..6d47e65 100644
--- a/game/StartGameScript.cpp
+++ b/game/StartGameScript.cpp
@@ -1,6 +1,9 @@
#include "StartGameScript.h"
+#include "Config.h"
+#include "api/BehaviorScript.h"
#include <crepe/api/Animator.h>
+#include <crepe/api/AudioSource.h>
#include <crepe/api/ParticleEmitter.h>
#include <crepe/api/Sprite.h>
@@ -9,7 +12,6 @@ using namespace std;
void StartGameScript::fixed_update(crepe::duration_t dt) {
Transform & player_transform = this->get_components_by_name<Transform>("player").front();
-
// Create hole in wall and activate panic lamp
if (player_transform.position.x > 75 && !this->created_hole) {
Sprite & lamp_sprite = this->get_components_by_name<Sprite>("start_end").back();
@@ -33,6 +35,14 @@ void StartGameScript::fixed_update(crepe::duration_t dt) {
emitter.active = true;
}
+ AudioSource & boom_audio
+ = this->get_components_by_name<AudioSource>("boom_audio").front();
+ boom_audio.play();
+
+ BehaviorScript & player_audio_script
+ = this->get_components_by_name<BehaviorScript>("player_audio").front();
+ player_audio_script.active = true;
+
this->created_hole = true;
}
@@ -44,13 +54,17 @@ void StartGameScript::fixed_update(crepe::duration_t dt) {
Sprite & jetpack_sprite = this->get_components_by_name<Sprite>("player").back();
jetpack_sprite.active = true;
+ AudioSource & background_music
+ = this->get_components_by_name<AudioSource>("background_music").front();
+ background_music.play(true);
+
this->took_jetpack = true;
}
// Start camera movement, enable player jumping and disable this script
if (player_transform.position.x > 500) {
Rigidbody & rb = this->get_components_by_name<Rigidbody>("camera").front();
- rb.data.linear_velocity = vec2(100, 0);
+ rb.data.linear_velocity = vec2(PLAYER_SPEED * 0.02, 0);
BehaviorScript & player_script
= this->get_components_by_name<BehaviorScript>("player").front();
player_script.active = true;