diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 14:50:04 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 14:50:04 +0100 |
commit | 0de6692dcb029540f4502c5a2f1a0c6634f7b61f (patch) | |
tree | 001f373de315b651704b8b264e20314bc878e288 /game/enemy/EnemyScript.cpp | |
parent | a4b9e948ac0acd14d82e009a75e1fccdddeeab9b (diff) |
start of extra features and restored player functions
Diffstat (limited to 'game/enemy/EnemyScript.cpp')
-rw-r--r-- | game/enemy/EnemyScript.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/game/enemy/EnemyScript.cpp b/game/enemy/EnemyScript.cpp index 6558af5..8e475a8 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -8,6 +8,8 @@ #include <crepe/api/ParticleEmitter.h> #include <crepe/api/Rigidbody.h> #include <crepe/api/Transform.h> +#include <crepe/api/AudioSource.h> +#include <crepe/api/Animator.h> #include <crepe/types.h> #include <random> using namespace crepe; @@ -82,8 +84,12 @@ bool EnemyScript::spawn_enemy(const SpawnEnemyEvent & e) { bool EnemyScript::on_collide(const CollisionEvent & e) { if (e.info.other.metadata.tag == "player_bullet") { - this->despawn_enemy(); + //this->despawn_enemy(); + } + Animator& body_animator = this->get_components<Animator>().front(); + body_animator.data.col = 2; + //body_animator.play(); BehaviorScript & enemy_script = this->get_component<BehaviorScript>(); enemy_script.active = false; return false; @@ -110,6 +116,8 @@ void EnemyScript::shoot(const vec2 & location, float angle) { = this->get_components_by_id<BoxCollider>(bullet_pos.game_object_id).front(); bullet_collider.active = true; bullet_body.active = true; + AudioSource& audio = this->get_component<AudioSource>(); + audio.play(); return; } } |