- [CHG] Retocat el mòdul JAudio per a adaptar-se a les necesitats del joc.

- [NEW] audio::getCurrentMusic()
- [NEW] audio::stopAllChannels()
- [FIX] El JAudio i JInput han de inicialitzarse abans de entrar al Init del joc
- Afegides músiques i alguns sons
- Comence a fer que sone cada musica i so en el seu lloc
- [TOFIX] LAG EN EL AUDIO!
This commit is contained in:
2024-10-03 13:09:44 +02:00
parent c92f2a13aa
commit e009aef341
20 changed files with 109 additions and 74 deletions

View File

@@ -2,6 +2,7 @@
#include "jgame.h"
#include "jinput.h"
#include "jdraw.h"
#include "jaudio.h"
#include <SDL2/SDL.h>
#include "config.h"
@@ -22,16 +23,27 @@ namespace modules
return MENU_AUDIO_TORNAR;
}
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
{
selected_option = (selected_option==2)?0:selected_option+1;
audio::playSound("snd_push.wav", SOUND_BASIC);
}
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
{
selected_option = (selected_option==0)?2:selected_option-1;
audio::playSound("snd_push.wav", SOUND_BASIC);
}
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
if (selected_option==MENU_AUDIO_MUSICA) config::toggleMusic();
if (selected_option==MENU_AUDIO_MUSICA) {
config::toggleMusic();
if (config::isMusicEnabled())
audio::playMusic("mus_menu.ogg");
else
audio::stopMusic();
}
if (selected_option==MENU_AUDIO_SO) config::toggleSound();
if (selected_option==MENU_AUDIO_TORNAR) return MENU_AUDIO_TORNAR;
audio::playSound("snd_push.wav", SOUND_BASIC);
}
draw::cls(2);