diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 12:17:30 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 12:17:30 +0100 |
commit | 1a5744a3285a5ba5132fb4f6f031c27df1b64d33 (patch) | |
tree | e1a893eadc08da75910cd4a4e4608959bffde1b7 /game/player/PlayerScript.cpp | |
parent | 49f0f0a24c1557a90530e0d2e0160e221644728a (diff) |
enemy death working
Diffstat (limited to 'game/player/PlayerScript.cpp')
-rw-r--r-- | game/player/PlayerScript.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/game/player/PlayerScript.cpp b/game/player/PlayerScript.cpp index 4e253f4..dc3eec3 100644 --- a/game/player/PlayerScript.cpp +++ b/game/player/PlayerScript.cpp @@ -61,7 +61,7 @@ bool PlayerScript::on_collision(const CollisionEvent & ev) { audio.play(); return false; - } else if (ev.info.other.metadata.tag == "missile") { + } else if (ev.info.other.metadata.tag == "missile" || ev.info.other.metadata.tag == "enemy_bullet") { for (Animator & anim : animators) { anim.active = true; anim.set_anim(5); @@ -157,21 +157,23 @@ void PlayerScript::fixed_update(crepe::duration_t dt) { } void PlayerScript::shoot(const vec2& location,float angle){ - cout << "player shot" << endl; - RefVector<Transform> bullet_transforms = this->get_components_by_tag<Transform>("PlayerBullet"); + //cout << "player shot" << endl; + RefVector<Transform> bullet_transforms = this->get_components_by_tag<Transform>("player_bullet"); for(Transform& bullet_pos : bullet_transforms){ //cout << "bullet pos x: " << bullet_pos.position.x << " y: " << bullet_pos.position.y << endl; if(bullet_pos.position.x == 0 && bullet_pos.position.y == -850){ - cout << "bullet found\n"; + //cout << "bullet found\n"; bullet_pos.position = location; bullet_pos.position.x += 20; - cout << "bullet pos x: " << bullet_pos.position.x << " y: " << bullet_pos.position.y << endl; + //cout << "bullet pos x: " << bullet_pos.position.x << " y: " << bullet_pos.position.y << endl; Rigidbody& bullet_body = this->get_components_by_id<Rigidbody>(bullet_pos.game_object_id).front(); BoxCollider bullet_collider = this->get_components_by_id<BoxCollider>(bullet_pos.game_object_id).front(); //bullet_collider.active = true; bullet_body.active = true; + BehaviorScript& bullet_script = this->get_components_by_id<BehaviorScript>(bullet_pos.game_object_id).front(); + bullet_script.active = true; return; } } |