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 ++++++ 1 file changed, 6 insertions(+) (limited to 'game/player/PlayerScript.cpp') 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) { -- cgit v1.2.3 From 8bd94b7a0a1eb7c2f6ca003fac95bea858671218 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Thu, 9 Jan 2025 14:51:48 +0100 Subject: removed player spawn battle --- game/player/PlayerScript.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'game/player/PlayerScript.cpp') diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp index c072e06..1283d0a 100644 --- a/game/player/PlayerScript.cpp +++ b/game/player/PlayerScript.cpp @@ -104,12 +104,7 @@ 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) { -- cgit v1.2.3 From 843d27e8f68bf3d3d39baedb7a5c53154160afd7 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Thu, 9 Jan 2025 14:54:40 +0100 Subject: fixed some player features --- game/player/PlayerScript.cpp | 1 - game/player/PlayerSubScene.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'game/player/PlayerScript.cpp') diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp index 1283d0a..fadca9c 100644 --- a/game/player/PlayerScript.cpp +++ b/game/player/PlayerScript.cpp @@ -104,7 +104,6 @@ void PlayerScript::fixed_update(crepe::duration_t dt) { last_fired = now; } } - 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/PlayerSubScene.cpp b/game/player/PlayerSubScene.cpp index 245f19c..dfcd763 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(200, 200)); + GameObject player = scn.new_object("player", "player", vec2(-100, 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(35, 35)); + player.add_component(vec2(50, 35)); Asset player_head_asset {"asset/barry/defaultHead.png"}; Sprite & player_head_sprite = player.add_component( player_head_asset, -- cgit v1.2.3 From a9c6e86e4d95f4f4986be9016779dcc26a925862 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Fri, 10 Jan 2025 11:10:05 +0100 Subject: animation working + removed bullet colliding with dead enemies --- game/enemy/EnemyBulletSubScene.cpp | 2 +- game/enemy/EnemyScript.cpp | 12 ++++++++---- game/enemy/EnemySubScene.cpp | 6 +++--- game/player/PlayerScript.cpp | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'game/player/PlayerScript.cpp') diff --git a/game/enemy/EnemyBulletSubScene.cpp b/game/enemy/EnemyBulletSubScene.cpp index 1406660..bc31ba8 100644 --- a/game/enemy/EnemyBulletSubScene.cpp +++ b/game/enemy/EnemyBulletSubScene.cpp @@ -30,7 +30,7 @@ int EnemyBulletSubScene::create(Scene & scn, int counter) { .body_type = Rigidbody::BodyType::KINEMATIC, .linear_velocity = vec2 {-300, 0}, .kinematic_collision = false, - .collision_layers = {COLL_LAY_BOT_TOP, COLL_LAY_MISSILE, COLL_LAY_ZAPPER}, + .collision_layers = {COLL_LAY_MISSILE, COLL_LAY_ZAPPER}, .collision_layer = COLL_LAY_BULLET }); bullet_body.active = false; diff --git a/game/enemy/EnemyScript.cpp b/game/enemy/EnemyScript.cpp index e3c8e9f..22431fd 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -82,6 +82,7 @@ bool EnemyScript::spawn_enemy(const SpawnEnemyEvent & e) { this->speed = e.speed; this->alive = true; this->spawned = true; + this->health = 2; RefVector animators = this->get_components(); for (Animator & anim : animators) { anim.active = false; @@ -99,7 +100,9 @@ bool EnemyScript::spawn_enemy(const SpawnEnemyEvent & e) { Transform & transform = this->get_component(); Camera & camera = this->get_components_by_name("camera").front(); Transform & cam_transform = this->get_components_by_name("camera").front(); - + Rigidbody& rb = this->get_component(); + rb.data.collision_layers = {COLL_LAY_BOT_TOP, COLL_LAY_PLAYER_BULLET}; + rb.data.collision_layer = COLL_LAY_ENEMY; vec2 half_screen = camera.viewport_size / 2; float x_value = cam_transform.position.x + half_screen.x - 40 * (1 + e.column); uniform_real_distribution dist( @@ -132,7 +135,6 @@ void EnemyScript::set_hit_blink(bool status) { bool EnemyScript::on_collide(const CollisionEvent & e) { if (!this->alive) return false; if (e.info.other.metadata.tag == "player_bullet") { - cout << "health: " << health << endl; this->health--; last_hit = std::chrono::steady_clock::now(); //Sprite& sprite; @@ -160,8 +162,10 @@ void EnemyScript::death() { sprite.data.position_offset.x = 15; } rb.data.linear_velocity_coefficient = {0.5, 1}; - //rb.add_force_linear(vec2{0,20}); - rb.data.gravity_scale = 20; + rb.data.collision_layers = {COLL_LAY_BOT_TOP}; + rb.data.collision_layer = 0; + + rb.data.gravity_scale = 1; tr.rotation = 90; AI & ai = this->get_component(); ai.active = false; diff --git a/game/enemy/EnemySubScene.cpp b/game/enemy/EnemySubScene.cpp index ed3e555..d1117d8 100644 --- a/game/enemy/EnemySubScene.cpp +++ b/game/enemy/EnemySubScene.cpp @@ -33,7 +33,7 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { }); // normal body Asset enemy_body_asset {"asset/workers/worker2Body.png"}; - enemy.add_component(vec2(50, 50)); + enemy.add_component(vec2(40, 60)); Sprite & enemy_body_sprite = enemy.add_component( enemy_body_asset, Sprite::Data { @@ -53,7 +53,7 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { } ); body_animator.pause(); - enemy.add_component(vec2(40, 60), vec2(-20, 0)); + Asset enemy_head_asset {"asset/workers/worker2Head.png"}; Sprite & enemy_head_sprite = enemy.add_component( enemy_head_asset, @@ -74,7 +74,7 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { ); //jetpack - enemy.add_component(25, vec2(0, -20)); + //enemy.add_component(25, vec2(0, -20)); Asset enemy_jetpack_asset {"asset/barry/jetpackDefault.png"}; Sprite & enemy_jetpack_sprite = enemy.add_component( enemy_jetpack_asset, diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp index c3843ca..0fadade 100644 --- a/game/player/PlayerScript.cpp +++ b/game/player/PlayerScript.cpp @@ -159,7 +159,7 @@ void PlayerScript::fixed_update(crepe::duration_t dt) { if (current_jetpack_sound > 7) { current_jetpack_sound = 0; } - } else if (transform.position.y == 195) { + } else if (transform.position.y == 200) { Rigidbody & rb = this->body; if (prev_anim != 0 && rb.data.linear_velocity.x != 0) { for (Animator & anim : animators) { -- cgit v1.2.3