Añadido sonido al sprite de la demo

This commit is contained in:
2023-05-07 10:07:06 +02:00
parent aeb508f936
commit f56837fc6c

View File

@@ -64,10 +64,10 @@ int main(int argc, char *argv[])
JA_Init(48000, AUDIO_S16, 2);
JA_Music_t *music;
JA_Sound_t *peiv;
JA_Sound_t *sound;
music = JA_LoadMusic(asset->get("music.ogg").c_str());
peiv = JA_LoadSound(asset->get("sound.wav").c_str());
sound = JA_LoadSound(asset->get("sound.wav").c_str());
int volume = 128;
// Inicializa el texto
@@ -124,10 +124,12 @@ int main(int argc, char *argv[])
if (sprite->getPosX() + sprite->getWidth() > options->gameWidth or sprite->getPosX() < 0)
{
sprite->setVelX(sprite->getVelX() * -1);
JA_PlaySound(sound);
}
if (sprite->getPosY() + sprite->getHeight() > options->gameHeight or sprite->getPosY() < 0)
{
sprite->setVelY(sprite->getVelY() * -1);
JA_PlaySound(sound);
}
sprite->update();
}
@@ -165,7 +167,7 @@ int main(int argc, char *argv[])
delete text;
// Finaliza jail_audio
JA_DeleteSound(peiv);
JA_DeleteSound(sound);
JA_DeleteMusic(music);
// Finaliza el objeto con la lista de recuros