aboutsummaryrefslogtreecommitdiff
path: root/game/player
diff options
context:
space:
mode:
Diffstat (limited to 'game/player')
-rw-r--r--game/player/PlayerEndScript.cpp7
-rw-r--r--game/player/PlayerScript.cpp6
-rw-r--r--game/player/PlayerSubScene.cpp2
3 files changed, 11 insertions, 4 deletions
diff --git a/game/player/PlayerEndScript.cpp b/game/player/PlayerEndScript.cpp
index e04fb9d..fb18f2f 100644
--- a/game/player/PlayerEndScript.cpp
+++ b/game/player/PlayerEndScript.cpp
@@ -1,6 +1,7 @@
#include "PlayerEndScript.h"
#include "../Config.h"
+#include "../Events.h"
#include "manager/LoopTimerManager.h"
#include <crepe/api/Animator.h>
@@ -89,7 +90,11 @@ bool PlayerEndScript::on_collision(const crepe::CollisionEvent & ev) {
jump++;
}
- return true;
+ if (rb_player.data.linear_velocity.x < 5) {
+ this->trigger_event<EndGameEvent>();
+ }
+
+ return false;
}
return false;
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp
index 4404bd8..d45a519 100644
--- a/game/player/PlayerScript.cpp
+++ b/game/player/PlayerScript.cpp
@@ -41,7 +41,7 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) {
AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(0);
audio.play();
- return true;
+ return false;
} else if (ev.info.other.metadata.tag == "laser") {
for (Animator & anim : animators) {
anim.active = true;
@@ -58,7 +58,7 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) {
AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(1);
audio.play();
- return true;
+ return false;
} else if (ev.info.other.metadata.tag == "missile") {
for (Animator & anim : animators) {
anim.active = true;
@@ -75,7 +75,7 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) {
AudioSource & audio = this->get_components_by_name<AudioSource>("player").at(2);
audio.play();
- return true;
+ return false;
}
return false;
diff --git a/game/player/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp
index e9e2167..f136605 100644
--- a/game/player/PlayerSubScene.cpp
+++ b/game/player/PlayerSubScene.cpp
@@ -4,6 +4,7 @@
#include "PlayerScript.h"
#include "../Config.h"
+#include "../coins/CoinScript.h"
#include "api/Asset.h"
#include <crepe/api/Animator.h>
@@ -152,6 +153,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) {
.collision_layer = COLL_LAY_PLAYER,
});
player.add_component<BehaviorScript>().set_script<PlayerScript>().active = false;
+ player.add_component<BehaviorScript>().set_script<CoinScript>();
player.add_component<BehaviorScript>().set_script<PlayerEndScript>().active = false;
player.add_component<AudioSource>(Asset("asset/sfx/dud_zapper_lp.ogg"));