diff --git a/demo/inc/states/game/enemy/enemy_info.hpp b/demo/inc/states/game/enemy/enemy_info.hpp index 044f448..2da3d85 100644 --- a/demo/inc/states/game/enemy/enemy_info.hpp +++ b/demo/inc/states/game/enemy/enemy_info.hpp @@ -21,7 +21,8 @@ namespace Demo { struct EnemyInfo { u8 adpcmChannel; - audsrv_adpcm_t* adpcmSample; + audsrv_adpcm_t* adpcmPunch; + audsrv_adpcm_t* adpcmDeath; DynamicMesh* motherMesh; Texture* bodyTexture; Texture* clothTexture; diff --git a/demo/inc/states/game/hud/hud.hpp b/demo/inc/states/game/hud/hud.hpp index d459c34..b13ac1a 100644 --- a/demo/inc/states/game/hud/hud.hpp +++ b/demo/inc/states/game/hud/hud.hpp @@ -26,10 +26,14 @@ class Hud { ~Hud(); TextureRepository* repo; - Texture* hpTexture; + unique_ptr hpSprite; - Texture* crosshairTexture; unique_ptr crosshairSprite; + unique_ptr soldierSprite; + + Texture* hpTexture; + Texture* crosshairTexture; + Texture* soldierTexture; }; } // namespace Demo diff --git a/demo/src/states/game/enemy/enemy.cpp b/demo/src/states/game/enemy/enemy.cpp index 5e525da..6381111 100644 --- a/demo/src/states/game/enemy/enemy.cpp +++ b/demo/src/states/game/enemy/enemy.cpp @@ -110,6 +110,7 @@ void Enemy::handlePlayerShoot(const PlayerShootAction& shootAction) { if (isOnEnemy) { setMeshToSpawn(); + audio->adpcm.tryPlay(info.adpcmDeath, info.adpcmChannel); } } @@ -144,7 +145,7 @@ void Enemy::fight() { void Enemy::animationCallback(const AnimationSequenceCallback& callback) { if (callback == AnimationSequenceCallback::AnimationSequenceCallback_Loop) { if (isFighting) { - audio->adpcm.tryPlay(info.adpcmSample, info.adpcmChannel); + audio->adpcm.tryPlay(info.adpcmPunch, info.adpcmChannel); } } } diff --git a/demo/src/states/game/enemy/enemy_manager.cpp b/demo/src/states/game/enemy/enemy_manager.cpp index 4438c19..9a839d1 100644 --- a/demo/src/states/game/enemy/enemy_manager.cpp +++ b/demo/src/states/game/enemy/enemy_manager.cpp @@ -40,14 +40,18 @@ EnemyManager::EnemyManager(Engine* engine, const Heightmap& heightmap) { clothTexture = textureRepo->add( FileUtils::fromCwd("game/models/zombie/ClothMaterial.png")); - auto* sample = engine->audio.adpcm.load( + auto* punch = engine->audio.adpcm.load( FileUtils::fromCwd("game/models/zombie/punch.adpcm")); + auto* death = engine->audio.adpcm.load( + FileUtils::fromCwd("game/models/zombie/death.adpcm")); + const int enemyCount = 10; for (int i = 0; i < enemyCount; i++) { EnemyInfo info; info.adpcmChannel = 9 + i; - info.adpcmSample = sample; + info.adpcmPunch = punch; + info.adpcmDeath = death; info.motherMesh = motherMesh; info.clothTexture = clothTexture; info.bodyTexture = bodyTexture; diff --git a/demo/src/states/game/game_state.cpp b/demo/src/states/game/game_state.cpp index d75fed7..686886e 100644 --- a/demo/src/states/game/game_state.cpp +++ b/demo/src/states/game/game_state.cpp @@ -84,6 +84,7 @@ void GameState::update() { firstEnemyMesh->getModelMatrix())); renderer.add(hud->crosshairSprite.get()); renderer.add(hud->hpSprite.get()); + renderer.add(hud->soldierSprite.get()); } renderer.render(); } diff --git a/demo/src/states/game/hud/hud.cpp b/demo/src/states/game/hud/hud.cpp index d6d98e8..7563b5d 100644 --- a/demo/src/states/game/hud/hud.cpp +++ b/demo/src/states/game/hud/hud.cpp @@ -17,10 +17,18 @@ namespace Demo { Hud::Hud(TextureRepository* t_repo) { repo = t_repo; + soldierSprite = std::make_unique(); + soldierSprite->mode = Tyra::MODE_STRETCH; + soldierSprite->size.set(64.0F, 64.0F); + soldierSprite->position.set(5.0F, 448.0F - 64.0F - 5.0F); + + soldierTexture = repo->add(FileUtils::fromCwd("game/soldier.png")); + soldierTexture->addLink(soldierSprite->id); + hpSprite = std::make_unique(); hpSprite->mode = Tyra::MODE_STRETCH; hpSprite->size.set(128.0F, 64.0F); - hpSprite->position.set(0, 448.0F - 64.0F - 5.0F); + hpSprite->position.set(70.0F, 448.0F - 64.0F - 5.0F); hpTexture = repo->add(FileUtils::fromCwd("game/health_bar.png")); hpTexture->addLink(hpSprite->id);