Added: Underwater/Above water soundscape, misc sound effects. Reworked player class a bit to contain pointer to the game engine for sound playing.

This commit is contained in:
Foxar
2020-12-09 14:27:40 +01:00
parent c4fc52b043
commit f86a1bf190
4 changed files with 50 additions and 2 deletions
+19
View File
@@ -32,6 +32,12 @@ Player::~Player()
{
}
void Player::init(Engine *t_engine)
{
pEngine = t_engine;
waterImpact = t_engine->audio.loadADPCM("sound/water_impact.sad");
}
void Player::update(Pad &t_pad)
{
if (lift > 0.0F)
@@ -81,6 +87,19 @@ void Player::update(Pad &t_pad)
printf("Swim animation\n");
mesh.playAnimation(1, 14, 0);
}
if (mesh.getCurrentAnimationFrame() == 42)
{
if (!bIsImpactingWater)
{
pEngine->audio.setADPCMVolume(50, 2);
pEngine->audio.playADPCM(waterImpact, 2);
}
bIsImpactingWater = true;
}
else if (bIsImpactingWater)
{
bIsImpactingWater = false;
}
velocity *= 60.0F / Dolphin::engineFPS; //Moving by deltatime of last frame.
mesh.position.z +=
+6 -1
View File
@@ -14,9 +14,10 @@
#define WATER_LEVEL -5.0F
#include "../camera.hpp"
#include <audsrv.h>
#include <modules/pad.hpp>
#include <tamtypes.h>
class Engine;
class Player
{
@@ -25,6 +26,7 @@ public:
Mesh mesh;
Player();
~Player();
void init(Engine *t_engine);
void update(Pad &t_pad);
const u8 &isJumping() { return bIsJumping; }
const u8 &getLifes() { return lifes; }
@@ -33,6 +35,9 @@ private:
u8 bIsJumping;
Vector3 playerNextPosition;
u8 lifes;
audsrv_adpcm_t *waterImpact;
Engine *pEngine;
u8 bIsImpactingWater;
};
#endif