diff options
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; } } |