diff --git a/data/Makefile.am b/data/Makefile.am index 36b52d2..d7af63a 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -153,6 +153,8 @@ nobase_dist_gamedata_DATA = images/background.png \ sounds/bag_place.wav \ sounds/bag_land.wav \ sounds/splop.wav \ + music/beans1.ogg \ + music/beans2.ogg \ klickclack.ttf \ burbanks.ttf \ comicrazybi.ttf diff --git a/data/music/beans1.ogg b/data/music/beans1.ogg new file mode 100644 index 0000000..0d40cd9 Binary files /dev/null and b/data/music/beans1.ogg differ diff --git a/data/music/beans2.ogg b/data/music/beans2.ogg new file mode 100644 index 0000000..18e10f0 Binary files /dev/null and b/data/music/beans2.ogg differ diff --git a/src/beans.c b/src/beans.c index 55907f9..160f6b3 100644 --- a/src/beans.c +++ b/src/beans.c @@ -361,6 +361,9 @@ const char *sound_names[NUM_SOUNDS] = { "sounds/bag_land.wav", }; +#define MUS_BEANS_1 "music/beans1.ogg" +#define MUS_BEANS_2 "music/beans2.ogg" + /* Para el motor de botones */ enum { BUTTON_NONE, @@ -675,7 +678,7 @@ Collider *colliders_hazard_fish[10]; int color_penguin = 0; Mix_Chunk * sounds[NUM_SOUNDS]; -Mix_Music * mus_carnie; +Mix_Music * music[2]; BeanBag *first_bag = NULL; BeanBag *last_bag = NULL; @@ -807,12 +810,20 @@ int game_intro (void) { SDL_BlitSurface (texts[TEXT_PLAY_GAME], NULL, screen, &rect); + Mix_VolumeMusic (MIX_MAX_VOLUME / 2); /* 50% */ + Mix_PlayMusic (music[0], 1); + SDL_Flip (screen); do { last_time = SDL_GetTicks (); num_rects = 0; + if (!Mix_PlayingMusic ()) { + map = RANDOM (2); + Mix_PlayMusic (music[map], 1); + } + while (SDL_PollEvent(&event) > 0) { switch (event.type) { case SDL_QUIT: @@ -1014,6 +1025,11 @@ int game_explain (void) { last_time = SDL_GetTicks (); num_rects = 0; + if (!Mix_PlayingMusic ()) { + map = RANDOM (2); + Mix_PlayMusic (music[map], 1); + } + while (SDL_PollEvent(&event) > 0) { /* fprintf (stdout, "Evento: %i\n", event.type);*/ switch (event.type) { @@ -1307,12 +1323,18 @@ int game_loop (void) { do { last_time = SDL_GetTicks (); + if (!Mix_PlayingMusic ()) { + map = RANDOM (2); + Mix_PlayMusic (music[map], 1); + } + while (SDL_PollEvent(&event) > 0) { switch (event.type) { case SDL_QUIT: /* Vamos a cerrar la aplicación */ done = GAME_QUIT; break; + case SDL_MOUSEBUTTONDOWN: /* Tengo un Mouse Down */ if (event.button.button != SDL_BUTTON_LEFT) break; @@ -2183,19 +2205,20 @@ void setup (void) { Mix_VolumeChunk (sounds[g], MIX_MAX_VOLUME / 2); } - /* Cargar la música */ - //sprintf (buffer_file, "%s%s", systemdata_path, MUS_CARNIE); - //mus_carnie = Mix_LoadMUS (buffer_file); + /* Cargar las músicas de fondo */ + sprintf (buffer_file, "%s%s", systemdata_path, MUS_BEANS_1); + music[0] = Mix_LoadMUS (buffer_file); + sprintf (buffer_file, "%s%s", systemdata_path, MUS_BEANS_2); + music[1] = Mix_LoadMUS (buffer_file); - /*if (mus_carnie == NULL) { + if (music[0] == NULL || music[1] == NULL) { fprintf (stderr, - _("Failed to load data file:\n" - "%s\n" + _("Failed to load a music file.\n" "The error returned by SDL is:\n" - "%s\n"), buffer_file, SDL_GetError ()); + "%s\n"), SDL_GetError ()); SDL_Quit (); exit (1); - }*/ + } } if (TTF_Init () < 0) {