From 7739a80176cea889ce240d18d354c5174825b25a Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Thu, 9 Jan 2025 14:46:30 +0100 Subject: workers during normal sequence working --- game/player/PlayerScript.cpp | 6 ++++++ game/player/PlayerScript.h | 5 ++++- game/player/PlayerSubScene.cpp | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'game/player') 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{ + .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 last_fired; + std::chrono::time_point last_switched; std::chrono::duration shot_delay = std::chrono::duration(0.5); - + std::chrono::duration switch_delay = std::chrono::duration(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( @@ -106,7 +106,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { .looping = true, } ); - player.add_component(vec2(50, 50)); + player.add_component(vec2(35, 35)); Asset player_head_asset {"asset/barry/defaultHead.png"}; Sprite & player_head_sprite = player.add_component( player_head_asset, @@ -143,7 +143,7 @@ PlayerSubScene::PlayerSubScene(Scene & scn) { .looping = true, } ); - player.add_component(vec2(40, 60), vec2(-20, 0)); + player.add_component(vec2(40, 50), vec2(-20, 0)); player.add_component(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().set_script().active = false; player.add_component().set_script(); player.add_component().set_script().active = false; -- cgit v1.2.3