aboutsummaryrefslogtreecommitdiff
path: root/game/enemy/EnemyBulletScript.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-08 12:17:30 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-08 12:17:30 +0100
commit1a5744a3285a5ba5132fb4f6f031c27df1b64d33 (patch)
treee1a893eadc08da75910cd4a4e4608959bffde1b7 /game/enemy/EnemyBulletScript.cpp
parent49f0f0a24c1557a90530e0d2e0160e221644728a (diff)
enemy death working
Diffstat (limited to 'game/enemy/EnemyBulletScript.cpp')
-rw-r--r--game/enemy/EnemyBulletScript.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/game/enemy/EnemyBulletScript.cpp b/game/enemy/EnemyBulletScript.cpp
index 561d086..ba27b9d 100644
--- a/game/enemy/EnemyBulletScript.cpp
+++ b/game/enemy/EnemyBulletScript.cpp
@@ -14,7 +14,9 @@ void EnemyBulletScript::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>();
+ //move
+ transform.position.x += bullet_body.data.linear_velocity.x * 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){
@@ -30,7 +32,7 @@ void EnemyBulletScript::despawn_bullet(){
}
bool EnemyBulletScript::on_collide(const CollisionEvent& e){
- cout << "collision happened with " << e.info.other.metadata.tag << endl;
- //this->despawn_bullet();
+ //cout << "collision happened with " << e.info.other.metadata.tag << endl;
+ this->despawn_bullet();
return false;
}