diff options
Diffstat (limited to 'game/enemy')
-rw-r--r-- | game/enemy/EnemyBulletSubScene.cpp | 2 | ||||
-rw-r--r-- | game/enemy/EnemyScript.cpp | 10 | ||||
-rw-r--r-- | game/enemy/EnemySubScene.cpp | 9 |
3 files changed, 15 insertions, 6 deletions
diff --git a/game/enemy/EnemyBulletSubScene.cpp b/game/enemy/EnemyBulletSubScene.cpp index edd8f0c..5c31f1d 100644 --- a/game/enemy/EnemyBulletSubScene.cpp +++ b/game/enemy/EnemyBulletSubScene.cpp @@ -30,7 +30,7 @@ int EnemyBulletSubScene::create(Scene & scn, int counter) { .linear_velocity = vec2 {-250, 0}, .kinematic_collision = false, - .collision_layers = {COLL_LAY_MISSILE}, + .collision_layers = {COLL_LAY_MISSILE,COLL_LAY_ZAPPER}, .collision_layer = COLL_LAY_BULLET }); bullet_body.active = false; 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; } } diff --git a/game/enemy/EnemySubScene.cpp b/game/enemy/EnemySubScene.cpp index 7d3e784..8316db9 100644 --- a/game/enemy/EnemySubScene.cpp +++ b/game/enemy/EnemySubScene.cpp @@ -8,6 +8,7 @@ #include <crepe/api/GameObject.h> #include <crepe/api/Rigidbody.h> #include <crepe/api/Scene.h> +#include <crepe/api/AudioSource.h> #include <crepe/api/Sprite.h> #include "../Config.h" @@ -45,9 +46,8 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { enemy_body_sprite, ivec2(32, 32), uvec2(4, 8), Animator::Data { .fps = 5, - .col = 3, - .row = 1, - + .col = 1, + .row = 0, .looping = false, } ); @@ -91,7 +91,8 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { .looping = true, } ); - + enemy.add_component<AudioSource>(Asset("asset/sfx/bike_gun_2.ogg")).volume + = 0.1; AI & ai_component = enemy.add_component<AI>(3000); ai_component.path_follow_on(); BehaviorScript & enemy_script |