aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/CMakeLists.txt2
-rw-r--r--game/GameScene.cpp3
-rw-r--r--game/player/PlayerEndScript.cpp (renamed from game/EndGameScript.cpp)6
-rw-r--r--game/player/PlayerEndScript.h (renamed from game/EndGameScript.h)2
-rw-r--r--game/player/PlayerScript.cpp3
-rw-r--r--game/player/PlayerSubScene.cpp2
6 files changed, 8 insertions, 10 deletions
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 33ceaf4..8e3692b 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -19,7 +19,7 @@ add_executable(main
player/PlayerScript.cpp
player/PlayerSubScene.cpp
StartGameScript.cpp
- EndGameScript.cpp
+ player/PlayerEndScript.cpp
background/StartSubScene.cpp
main.cpp
)
diff --git a/game/GameScene.cpp b/game/GameScene.cpp
index b471484..821191d 100644
--- a/game/GameScene.cpp
+++ b/game/GameScene.cpp
@@ -1,6 +1,5 @@
#include "GameScene.h"
#include "Config.h"
-#include "EndGameScript.h"
#include "MoveCameraManualyScript.h"
#include "StartGameScript.h"
@@ -67,8 +66,6 @@ void GameScene::load_scene() {
GameObject start_game_script = new_object("start_game_script", "script", vec2(0, 0));
start_game_script.add_component<BehaviorScript>().set_script<StartGameScript>();
- GameObject end_game_script = new_object("end_game_script", "script", vec2(0, 0));
- end_game_script.add_component<BehaviorScript>().set_script<EndGameScript>().active = false;
// zapper, laser and missile (below) for testing purpose only!!!
GameObject zapper = new_object("zapper", "zapper", vec2(1000, 0));
diff --git a/game/EndGameScript.cpp b/game/player/PlayerEndScript.cpp
index a18f18c..c0b4e74 100644
--- a/game/EndGameScript.cpp
+++ b/game/player/PlayerEndScript.cpp
@@ -1,4 +1,4 @@
-#include "EndGameScript.h"
+#include "PlayerEndScript.h"
#include <crepe/api/Animator.h>
#include <crepe/api/BoxCollider.h>
@@ -9,14 +9,14 @@
using namespace crepe;
using namespace std;
-void EndGameScript::init() {
+void PlayerEndScript::init() {
BoxCollider jetpack_coll = this->get_components_by_name<BoxCollider>("player").back();
CircleCollider head_coll = this->get_components_by_name<CircleCollider>("player").back();
jetpack_coll.active = false;
head_coll.active = false;
}
-void EndGameScript::fixed_update(crepe::duration_t dt) {
+void PlayerEndScript::fixed_update(crepe::duration_t dt) {
Transform & transform_player = this->get_components_by_name<Transform>("player").front();
RefVector<Animator> anim_player = this->get_components_by_name<Animator>("player");
Rigidbody & rb_player = this->get_components_by_name<Rigidbody>("player").front();
diff --git a/game/EndGameScript.h b/game/player/PlayerEndScript.h
index 980dff5..240ab7c 100644
--- a/game/EndGameScript.h
+++ b/game/player/PlayerEndScript.h
@@ -2,7 +2,7 @@
#include <crepe/api/Script.h>
-class EndGameScript : public crepe::Script {
+class PlayerEndScript : public crepe::Script {
public:
void init();
void fixed_update(crepe::duration_t dt);
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp
index de53fc7..7f5d0c4 100644
--- a/game/player/PlayerScript.cpp
+++ b/game/player/PlayerScript.cpp
@@ -18,8 +18,7 @@ void PlayerScript::init() {
bool PlayerScript::on_collision(const CollisionEvent & ev) {
BehaviorScript & play_scr = this->get_components_by_name<BehaviorScript>("player").front();
- BehaviorScript & end_scr
- = this->get_components_by_name<BehaviorScript>("end_game_script").front();
+ BehaviorScript & end_scr = this->get_components_by_name<BehaviorScript>("player").back();
RefVector<Animator> animators = this->get_components_by_name<Animator>("player");
RefVector<ParticleEmitter> emitters
= this->get_components_by_name<ParticleEmitter>("player");
diff --git a/game/player/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp
index 812d99a..91ae882 100644
--- a/game/player/PlayerSubScene.cpp
+++ b/game/player/PlayerSubScene.cpp
@@ -1,4 +1,5 @@
#include "PlayerSubScene.h"
+#include "PlayerEndScript.h"
#include "PlayerScript.h"
#include "../Config.h"
@@ -148,4 +149,5 @@ PlayerSubScene::PlayerSubScene(Scene & scn) {
.collision_layer = COLL_LAY_PLAYER,
});
player.add_component<BehaviorScript>().set_script<PlayerScript>().active = false;
+ player.add_component<BehaviorScript>().set_script<PlayerEndScript>().active = false;
}