demo finish
This commit is contained in:
@@ -21,7 +21,8 @@ namespace Demo {
|
|||||||
|
|
||||||
struct EnemyInfo {
|
struct EnemyInfo {
|
||||||
u8 adpcmChannel;
|
u8 adpcmChannel;
|
||||||
audsrv_adpcm_t* adpcmSample;
|
audsrv_adpcm_t* adpcmPunch;
|
||||||
|
audsrv_adpcm_t* adpcmDeath;
|
||||||
DynamicMesh* motherMesh;
|
DynamicMesh* motherMesh;
|
||||||
Texture* bodyTexture;
|
Texture* bodyTexture;
|
||||||
Texture* clothTexture;
|
Texture* clothTexture;
|
||||||
|
|||||||
@@ -26,10 +26,14 @@ class Hud {
|
|||||||
~Hud();
|
~Hud();
|
||||||
|
|
||||||
TextureRepository* repo;
|
TextureRepository* repo;
|
||||||
Texture* hpTexture;
|
|
||||||
unique_ptr<Sprite> hpSprite;
|
unique_ptr<Sprite> hpSprite;
|
||||||
Texture* crosshairTexture;
|
|
||||||
unique_ptr<Sprite> crosshairSprite;
|
unique_ptr<Sprite> crosshairSprite;
|
||||||
|
unique_ptr<Sprite> soldierSprite;
|
||||||
|
|
||||||
|
Texture* hpTexture;
|
||||||
|
Texture* crosshairTexture;
|
||||||
|
Texture* soldierTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Demo
|
} // namespace Demo
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ void Enemy::handlePlayerShoot(const PlayerShootAction& shootAction) {
|
|||||||
|
|
||||||
if (isOnEnemy) {
|
if (isOnEnemy) {
|
||||||
setMeshToSpawn();
|
setMeshToSpawn();
|
||||||
|
audio->adpcm.tryPlay(info.adpcmDeath, info.adpcmChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +145,7 @@ void Enemy::fight() {
|
|||||||
void Enemy::animationCallback(const AnimationSequenceCallback& callback) {
|
void Enemy::animationCallback(const AnimationSequenceCallback& callback) {
|
||||||
if (callback == AnimationSequenceCallback::AnimationSequenceCallback_Loop) {
|
if (callback == AnimationSequenceCallback::AnimationSequenceCallback_Loop) {
|
||||||
if (isFighting) {
|
if (isFighting) {
|
||||||
audio->adpcm.tryPlay(info.adpcmSample, info.adpcmChannel);
|
audio->adpcm.tryPlay(info.adpcmPunch, info.adpcmChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,14 +40,18 @@ EnemyManager::EnemyManager(Engine* engine, const Heightmap& heightmap) {
|
|||||||
clothTexture = textureRepo->add(
|
clothTexture = textureRepo->add(
|
||||||
FileUtils::fromCwd("game/models/zombie/ClothMaterial.png"));
|
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"));
|
FileUtils::fromCwd("game/models/zombie/punch.adpcm"));
|
||||||
|
|
||||||
|
auto* death = engine->audio.adpcm.load(
|
||||||
|
FileUtils::fromCwd("game/models/zombie/death.adpcm"));
|
||||||
|
|
||||||
const int enemyCount = 10;
|
const int enemyCount = 10;
|
||||||
for (int i = 0; i < enemyCount; i++) {
|
for (int i = 0; i < enemyCount; i++) {
|
||||||
EnemyInfo info;
|
EnemyInfo info;
|
||||||
info.adpcmChannel = 9 + i;
|
info.adpcmChannel = 9 + i;
|
||||||
info.adpcmSample = sample;
|
info.adpcmPunch = punch;
|
||||||
|
info.adpcmDeath = death;
|
||||||
info.motherMesh = motherMesh;
|
info.motherMesh = motherMesh;
|
||||||
info.clothTexture = clothTexture;
|
info.clothTexture = clothTexture;
|
||||||
info.bodyTexture = bodyTexture;
|
info.bodyTexture = bodyTexture;
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ void GameState::update() {
|
|||||||
firstEnemyMesh->getModelMatrix()));
|
firstEnemyMesh->getModelMatrix()));
|
||||||
renderer.add(hud->crosshairSprite.get());
|
renderer.add(hud->crosshairSprite.get());
|
||||||
renderer.add(hud->hpSprite.get());
|
renderer.add(hud->hpSprite.get());
|
||||||
|
renderer.add(hud->soldierSprite.get());
|
||||||
}
|
}
|
||||||
renderer.render();
|
renderer.render();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,18 @@ namespace Demo {
|
|||||||
Hud::Hud(TextureRepository* t_repo) {
|
Hud::Hud(TextureRepository* t_repo) {
|
||||||
repo = t_repo;
|
repo = t_repo;
|
||||||
|
|
||||||
|
soldierSprite = std::make_unique<Sprite>();
|
||||||
|
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<Sprite>();
|
hpSprite = std::make_unique<Sprite>();
|
||||||
hpSprite->mode = Tyra::MODE_STRETCH;
|
hpSprite->mode = Tyra::MODE_STRETCH;
|
||||||
hpSprite->size.set(128.0F, 64.0F);
|
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 = repo->add(FileUtils::fromCwd("game/health_bar.png"));
|
||||||
hpTexture->addLink(hpSprite->id);
|
hpTexture->addLink(hpSprite->id);
|
||||||
|
|||||||
Reference in New Issue
Block a user