diff --git a/source/jaudio.cpp b/source/jaudio.cpp index 31e63a9..da0205c 100644 --- a/source/jaudio.cpp +++ b/source/jaudio.cpp @@ -14,12 +14,18 @@ namespace audio JA_Sound_t *chunk; }; + struct music_cache_t + { + std::string name; + JA_Music_t *chunk; + }; + //char *music_buffer = nullptr; //JA_Music_t *music = nullptr; std::vector sounds; - std::vector songs; + std::vector songs; std::string musica_actual = ""; - int musica = -1; + //int musica = -1; // Inicialitza el sistema de só void init() @@ -33,7 +39,7 @@ namespace audio void quit() { //if (music) JA_DeleteMusic(music); - for (auto sound : songs) JA_DeleteSound(sound.chunk); + for (auto music : songs) JA_DeleteMusic(music.chunk); songs.clear(); for (auto sound : sounds) JA_DeleteSound(sound.chunk); // Mix_FreeChunk(sound.chunk); sounds.clear(); @@ -44,12 +50,12 @@ namespace audio { int size; char *buffer = file::getFileBuffer(filename, size); - auto chunk = JA_LoadSound((uint8_t *)buffer, size); + auto chunk = JA_LoadMusic((uint8_t *)buffer, size); free(buffer); //auto chunk = Mix_LoadWAV_RW(SDL_RWFromMem(buffer, size), 1); //if (!chunk) printf("ERROR: %s\n", SDL_GetError()); - sound_cache_t sound = { filename, chunk }; + music_cache_t sound = { filename, chunk }; songs.push_back(sound); } @@ -66,12 +72,15 @@ namespace audio //free(buffer); //JA_PlayMusic(music, loop); + //int song_index = 0; for (auto song : songs) { if (song.name == filename) { - musica = JA_PlaySound(song.chunk, loop); + JA_PlayMusic(song.chunk, loop); + //musica = song_index; musica_actual = filename; return; + //song_index++; } } } @@ -79,24 +88,24 @@ namespace audio // Pausa la música que està sonant ara void pauseMusic() { - //JA_PauseMusic(); //Mix_PauseMusic(); - if (musica != -1) JA_PauseChannel(musica); + JA_PauseMusic(); //Mix_PauseMusic(); + //if (musica != -1) JA_PauseChannel(musica); } // Continua la música pausada void resumeMusic() { if (!config::isMusicEnabled()) return; - //JA_ResumeMusic(); //Mix_ResumeMusic(); - if (musica != -1) JA_ResumeChannel(musica); + JA_ResumeMusic(); //Mix_ResumeMusic(); + //if (musica != -1) JA_ResumeChannel(musica); } // Para la música que estava sonant void stopMusic() { - //JA_StopMusic(); //Mix_HaltMusic(); - if (musica != -1) JA_StopChannel(musica); - musica = -1; + JA_StopMusic(); //Mix_HaltMusic(); + //if (musica != -1) JA_StopChannel(musica); + //musica = -1; musica_actual = ""; } diff --git a/source/m_menu.cpp b/source/m_menu.cpp index a91578c..d3c1b33 100644 --- a/source/m_menu.cpp +++ b/source/m_menu.cpp @@ -7,6 +7,8 @@ #include #include "jaudio.h" #include "actor.h" +#include "versio.h" + namespace modules { namespace menu @@ -122,7 +124,7 @@ namespace modules //draw::print2(input::getPadBtnPressed(), 3, 0, 24, RED, FONT_ZOOM_NONE); draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE); - draw::print("v1.5b", 299, 233, WHITE, PAPER); + draw::print(VERSIO, 299, 233, WHITE, PAPER); draw::render(); return OPTION_NONE; diff --git a/source/main.cpp b/source/main.cpp index aba56f5..f0298c3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -116,14 +116,14 @@ void game::init() draw::init("The Pool", 320, 240, zoom, fullscreen); console::init(); - printf("Carregant mus_menu.ogg..."); + printf("Carregant mus_menu.ogg...\n"); audio::loadMusic("mus_menu.ogg"); - printf("Carregant mus_ingame.ogg..."); + printf("Carregant mus_ingame.ogg...\n"); audio::loadMusic("mus_ingame.ogg"); - printf("Carregant mus_gameover.ogg..."); + printf("Carregant mus_gameover.ogg...\n"); audio::loadMusic("mus_gameover.ogg"); - printf("Carregant arxius de só..."); + printf("Carregant arxius de só...\n"); audio::loadSound("snd_logo.wav"); audio::loadSound("snd_walk.wav"); audio::loadSound("snd_push.wav"); diff --git a/source/versio.h b/source/versio.h new file mode 100644 index 0000000..412c44b --- /dev/null +++ b/source/versio.h @@ -0,0 +1,3 @@ +#pragma once + +#define VERSIO "v1.6"