aboutsummaryrefslogtreecommitdiff
path: root/game/player
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-09 14:46:30 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-09 14:46:30 +0100
commit7739a80176cea889ce240d18d354c5174825b25a (patch)
treee61974e217791cd86f519bf1c4cfd3b082d55166 /game/player
parent8b32dbc33c434f84b4aab98819147c3b8416ff69 (diff)
workers during normal sequence working
Diffstat (limited to 'game/player')
-rw-r--r--game/player/PlayerScript.cpp6
-rw-r--r--game/player/PlayerScript.h5
-rw-r--r--game/player/PlayerSubScene.cpp7
3 files changed, 14 insertions, 4 deletions
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp
index fadca9c..c072e06 100644
--- a/game/player/PlayerScript.cpp
+++ b/game/player/PlayerScript.cpp
@@ -104,6 +104,12 @@ void PlayerScript::fixed_update(crepe::duration_t dt) {
last_fired = now;
}
}
+ if (this->get_key_state(Keycode::P)) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent{
+ .num_enemies = 4,
+ .battle = true,
+ });
+ }
if (this->get_key_state(Keycode::SPACE)) {
rb.add_force_linear(vec2(0, -PLAYER_GRAVITY_SCALE / 2.5) * dt.count() / 0.02);
if (prev_anim != 1) {
diff --git a/game/player/PlayerScript.h b/game/player/PlayerScript.h
index e7d860a..0fe21d1 100644
--- a/game/player/PlayerScript.h
+++ b/game/player/PlayerScript.h
@@ -15,8 +15,11 @@ private:
private:
int prev_anim = 0;
+ bool gravity_mode = true;
+ bool fall_direction = false;
std::chrono::time_point<std::chrono::steady_clock> last_fired;
+ std::chrono::time_point<std::chrono::steady_clock> last_switched;
std::chrono::duration<float> shot_delay = std::chrono::duration<float>(0.5);
-
+ std::chrono::duration<float> switch_delay = std::chrono::duration<float>(0.01);
int current_jetpack_sound = 0;
};
diff --git a/game/player/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp
index c4d689a..245f19c 100644
--- a/game/player/PlayerSubScene.cpp
+++ b/game/player/PlayerSubScene.cpp
@@ -22,7 +22,7 @@ using namespace crepe;
using namespace std;
PlayerSubScene::PlayerSubScene(Scene & scn) {
- GameObject player = scn.new_object("player", "player", vec2(-100, 200));
+ GameObject player = scn.new_object("player", "player", vec2(200, 200));
Asset player_bullet {"asset/other_effects/effect_smgbullet.png"};
Sprite & player_bullet_sprite = player.add_component<Sprite>(
@@ -106,7 +106,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) {
.looping = true,
}
);
- player.add_component<BoxCollider>(vec2(50, 50));
+ player.add_component<BoxCollider>(vec2(35, 35));
Asset player_head_asset {"asset/barry/defaultHead.png"};
Sprite & player_head_sprite = player.add_component<Sprite>(
player_head_asset,
@@ -143,7 +143,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) {
.looping = true,
}
);
- player.add_component<BoxCollider>(vec2(40, 60), vec2(-20, 0));
+ player.add_component<BoxCollider>(vec2(40, 50), vec2(-20, 0));
player.add_component<Rigidbody>(Rigidbody::Data {
.gravity_scale = PLAYER_GRAVITY_SCALE,
.body_type = Rigidbody::BodyType::DYNAMIC,
@@ -153,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;