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/PlayerBulletScript.cpp | |
parent | 49f0f0a24c1557a90530e0d2e0160e221644728a (diff) |
enemy death working
Diffstat (limited to 'game/player/PlayerBulletScript.cpp')
-rw-r--r-- | game/player/PlayerBulletScript.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/game/player/PlayerBulletScript.cpp b/game/player/PlayerBulletScript.cpp index 50b6617..2bd067d 100644 --- a/game/player/PlayerBulletScript.cpp +++ b/game/player/PlayerBulletScript.cpp @@ -17,7 +17,9 @@ void PlayerBulletScript::fixed_update(crepe::duration_t dt){ Transform& transform = this->get_component<Transform>(); Camera& camera = this->get_components_by_name<Camera>("camera").front(); Transform& cam_transform = this->get_components_by_name<Transform>("camera").front(); - + Rigidbody& bullet_body = this->get_component<Rigidbody>(); + transform.rotation += bullet_body.data.angular_velocity; + transform.position += bullet_body.data.linear_velocity * dt.count(); vec2 half_screen = camera.viewport_size / 2; float despawn_location = cam_transform.position.x + half_screen.x + 50; if(transform.position.x > despawn_location){ @@ -29,11 +31,13 @@ void PlayerBulletScript::despawn_bullet(){ Transform& transform = this->get_component<Transform>(); Rigidbody& bullet_body = this->get_component<Rigidbody>(); bullet_body.active = false; + BehaviorScript& bullet_script = this->get_component<BehaviorScript>(); + bullet_script.active = false; transform.position = {0,-850}; } bool PlayerBulletScript::on_collide(const CollisionEvent& e){ - cout << "collision happened with " << e.info.other.metadata.tag << endl; - //this->despawn_bullet(); + cout << "player bullet collision happened with " << e.info.other.metadata.tag << endl; + this->despawn_bullet(); return false; } |