Compare commits
4 Commits
13ba26fb0e
...
ece24d4562
| Author | SHA1 | Date | |
|---|---|---|---|
| ece24d4562 | |||
| 1fd9d919c5 | |||
| a9357c6638 | |||
| d20bc2ef73 |
@@ -1,4 +1,4 @@
|
||||
PLAYMUSIC 'mus3.mp3'
|
||||
PLAYMUSIC 'mus3.ogg'
|
||||
FADEIN 'SEQ11.GIF'
|
||||
PRINT 139 19 2 'AU A LA JAIL!'
|
||||
ESPERAR 1000
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
PLAYMUSIC 'mus1.mp3'
|
||||
PLAYMUSIC 'mus1.ogg'
|
||||
FADEIN 'jailgames.gif'
|
||||
ESPERAR 4000
|
||||
FADEOUTMUSIC
|
||||
PLAYMUSIC 'mus2.mp3'
|
||||
PLAYMUSIC 'mus2.ogg'
|
||||
FADEIN 'THX.GIF'
|
||||
ESPERAR 4000
|
||||
FADEOUTMUSIC
|
||||
PLAYMUSIC 'mus3.mp3'
|
||||
PLAYMUSIC 'mus3.ogg'
|
||||
FADEIN 'intro01.GIF'
|
||||
PRINT 39 149 0 '8 DEL MATI'
|
||||
ESPERAR 1000
|
||||
@@ -21,6 +21,7 @@ FADEOUT
|
||||
FADEIN 'intro03.GIF'
|
||||
PRINT 119 19 1 '"COGEMOL EL INDIVIDUOL'
|
||||
PRINT 119 26 1 'Y PULSANDOL EL BOTOL....'
|
||||
ESPERAR 3000
|
||||
SHOW 'intro03.GIF'
|
||||
PRINT 120 19 1 '...CONSEGUIMOL VARIOL'
|
||||
PRINT 120 26 1 'INDIVIDUOL..."'
|
||||
|
||||
@@ -57,9 +57,13 @@ namespace gamestate
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (draw::isfading()) {
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
|
||||
{
|
||||
if (!draw::isfading() && (input::anyKeyPressed() || input::mouseBtn(1))) {
|
||||
if (input::anyKeyPressed() || input::mouseBtn(1)) {
|
||||
wait_until=0;
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) fseek(sequence_file, 0, SEEK_END);
|
||||
} else {
|
||||
@@ -67,6 +71,7 @@ namespace gamestate
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (feof(sequence_file))
|
||||
{
|
||||
fclose(sequence_file);
|
||||
@@ -90,14 +95,13 @@ namespace gamestate
|
||||
|
||||
if (command=="ESPERAR") {
|
||||
int res = fscanf(sequence_file, "%i", &val);
|
||||
printf("ESPERAR %i\n", val);
|
||||
wait_until = SDL_GetTicks() + val;
|
||||
|
||||
} else if (command=="FADEIN") {
|
||||
int res = fscanf(sequence_file, " '%[^']'", text);
|
||||
drawPic(text);
|
||||
draw::fadein();
|
||||
draw::render();
|
||||
wait_until = SDL_GetTicks() + 500;
|
||||
|
||||
} else if (command=="SHOW") {
|
||||
int res = fscanf(sequence_file, " '%[^']'", text);
|
||||
@@ -114,12 +118,10 @@ namespace gamestate
|
||||
|
||||
} else if (command=="FADEOUT") {
|
||||
draw::fadeout();
|
||||
wait_until = SDL_GetTicks() + 500;
|
||||
|
||||
} else if (command=="FADEOUTMUSIC") {
|
||||
draw::fadeout();
|
||||
audio::fadeoutMusic();
|
||||
wait_until = SDL_GetTicks() + 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@ namespace audio
|
||||
struct sound
|
||||
{
|
||||
}; // Dummy structs
|
||||
struct music
|
||||
{
|
||||
};
|
||||
|
||||
// Inicialitza el sistema de só
|
||||
void init()
|
||||
@@ -35,34 +32,25 @@ namespace audio
|
||||
}
|
||||
|
||||
// Carrega un arxiu de música en format OGG
|
||||
const music *loadMusic(const std::string filename)
|
||||
music *loadMusic(const std::string filename)
|
||||
{
|
||||
size_t index = 0;
|
||||
index = filename.find("mp3", index);
|
||||
std::string peiv(filename);
|
||||
peiv.replace(index, 3, "ogg");
|
||||
|
||||
printf("Loading '%s'...", peiv.c_str());
|
||||
|
||||
int filesize=0;
|
||||
char *buffer = file::getFileBuffer(peiv, filesize);
|
||||
const music* m = (music *)Mix_LoadMUS_RW(SDL_RWFromMem(buffer, filesize), 1);
|
||||
|
||||
// [TODO] ATENCIÓ. Ací leakeja com un burro, algo hi ha que inventar, pero el buffer ha de sobreviure tot el temps que dure la musica viva
|
||||
//free(buffer);
|
||||
char *buffer = file::getFileBuffer(filename, filesize);
|
||||
const Mix_Music* m = Mix_LoadMUS_RW(SDL_RWFromMem(buffer, filesize), 1);
|
||||
|
||||
if (m==nullptr) {
|
||||
printf("FAILED!\n");
|
||||
} else {
|
||||
printf("OK!\n");
|
||||
}
|
||||
return m;
|
||||
if (m==nullptr) return nullptr;
|
||||
|
||||
music *mus = (music *)malloc(sizeof(music));
|
||||
mus->buffer = buffer;
|
||||
mus->music = (void*)m;
|
||||
|
||||
return mus;
|
||||
}
|
||||
|
||||
// Comença a reproduïr la música en questió
|
||||
void playMusic(const music *mus, const int loop)
|
||||
{
|
||||
if (Mix_PlayMusic((Mix_Music *)mus, loop) == -1) {
|
||||
if (Mix_PlayMusic((Mix_Music *)mus->music, loop) == -1) {
|
||||
printf("Failed Mix_PlayMusic()\n");
|
||||
}
|
||||
}
|
||||
@@ -111,7 +99,9 @@ namespace audio
|
||||
// Allibera una música
|
||||
void deleteMusic(music *mus)
|
||||
{
|
||||
Mix_FreeMusic((Mix_Music *)mus);
|
||||
Mix_FreeMusic((Mix_Music *)mus->music);
|
||||
free(mus->buffer);
|
||||
free(mus);
|
||||
}
|
||||
|
||||
// Carrega un só des d'un arxiu WAV
|
||||
|
||||
@@ -23,7 +23,11 @@ namespace audio
|
||||
|
||||
// Estructures per a gestionar música i só
|
||||
struct sound;
|
||||
struct music;
|
||||
struct music
|
||||
{
|
||||
char *buffer;
|
||||
void *music;
|
||||
};
|
||||
|
||||
/// @brief Inicialitza el sistema de só
|
||||
void init();
|
||||
@@ -34,7 +38,7 @@ namespace audio
|
||||
/// @brief Carrega un arxiu de música en format OGG
|
||||
/// @param filename nom de l'arxiu
|
||||
/// @return punter a la música
|
||||
const music *loadMusic(const std::string filename);
|
||||
music *loadMusic(const std::string filename);
|
||||
|
||||
/// @brief Comença a reproduïr la música en questió
|
||||
/// @param mus punter a la música
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace draw
|
||||
// [TODO] Incloure gestió de pantalla completa
|
||||
|
||||
// Inicialització de les estructures de SDL
|
||||
sdl_window = SDL_CreateWindow(titol.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width * zoom, height * zoom, SDL_WINDOW_SHOWN);
|
||||
sdl_window = SDL_CreateWindow(titol.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width * zoom, height * zoom, SDL_WINDOW_SHOWN);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
|
||||
@@ -140,8 +140,11 @@ namespace draw
|
||||
uint32_t *pal = LoadPalette(buffer, &paletteSize);
|
||||
|
||||
// Copiem eixe array al nostre array de la paleta de sistema. Ara ja tenim la paleta carregada.
|
||||
memset(palette, 0, 1024); // Fiquem tot a 0, que la paleta potser no es de 256 i quedaria basura
|
||||
memcpy(palette, pal, paletteSize*4); // 32 bits per entrada == 4 bytes x 'paletteSize' entrades
|
||||
for (int i=0;i<256;++i) {
|
||||
palette[i] = i<paletteSize ? pal[i] : pal[i] = 0;
|
||||
}
|
||||
//memset(palette, 0, 1024); // Fiquem tot a 0, que la paleta potser no es de 256 i quedaria basura
|
||||
//memcpy(palette, pal, paletteSize*4); // 32 bits per entrada == 4 bytes x 'paletteSize' entrades
|
||||
|
||||
// Alliberem el array que ens habia tornat LoadPalette()
|
||||
free(pal);
|
||||
|
||||
Reference in New Issue
Block a user