Agrego sonidos.

master
Félix Arreola Rodríguez 2020-01-28 17:57:16 -06:00
parent b7eecc4800
commit 63f9fd9d09
14 changed files with 57 additions and 12 deletions

View File

@ -142,6 +142,16 @@ nobase_dist_gamedata_DATA = images/background.png \
images/intro_plataform.png \ images/intro_plataform.png \
images/left.png \ images/left.png \
images/right.png \ images/right.png \
sounds/truck_reverse.wav \
sounds/truck.wav \
sounds/toonhit.wav \
sounds/fish.wav \
sounds/vase.wav \
sounds/anvil.wav \
sounds/boing.wav \
sounds/bag_place.wav \
sounds/bag_land.wav \
sounds/splop.wav \
klickclack.ttf \ klickclack.ttf \
burbanks.ttf burbanks.ttf

BIN
data/burbanks.ttf 100644

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -345,13 +345,37 @@ const char *images_names[NUM_IMAGES] = {
}; };
enum { enum {
SND_NONE, SND_TRUCK_REVERSE,
SND_TRUCK,
SND_TOONHIT,
SND_FISH,
SND_VASE,
SND_ANVIL,
SND_SPLOP,
SND_BOING,
SND_BAG_PLACE,
SND_BAG_LAND,
NUM_SOUNDS NUM_SOUNDS
}; };
const char *sound_names[NUM_SOUNDS] = { const char *sound_names[NUM_SOUNDS] = {
"sounds/none.wav", "sounds/truck_reverse.wav",
"sounds/truck.wav",
"sounds/toonhit.wav",
"sounds/fish.wav",
"sounds/vase.wav",
"sounds/anvil.wav",
"sounds/splop.wav",
"sounds/boing.wav",
"sounds/bag_place.wav",
"sounds/bag_land.wav",
}; };
/* Para el motor de botones */ /* Para el motor de botones */
@ -1683,7 +1707,8 @@ int game_loop (void) {
snprintf (buffer, sizeof (buffer), "%d", score); snprintf (buffer, sizeof (buffer), "%d", score);
score_p = draw_text_with_shadow (ttf24_klickclack, 2, buffer, blanco, negro); score_p = draw_text_with_shadow (ttf24_klickclack, 2, buffer, blanco, negro);
} }
/* TODO: Sonido de poner bolsa */
if (use_sound) Mix_PlayChannel (-1, sounds[SND_BAG_PLACE], 0);
if (bag_stack == (nivel + 1) * 10) { if (bag_stack == (nivel + 1) * 10) {
/* Activar la pantalla de next_level */ /* Activar la pantalla de next_level */
@ -1787,11 +1812,12 @@ int game_loop (void) {
k = COLLIDER_PENGUIN_1 + bags; k = COLLIDER_PENGUIN_1 + bags;
/* Reproducir el sonido de "Agarrar bolsa" */ if (use_sound) Mix_PlayChannel (-1, sounds[SND_BAG_LAND], 0);
if (bags >= 6) { if (bags >= 6) {
/* Esta bolsa crasheó al pingüino */ /* Esta bolsa crasheó al pingüino */
printf ("Penguin Crash\n"); printf ("Penguin Crash\n");
if (use_sound) Mix_PlayChannel (-1, sounds[SND_TOONHIT], 0);
if (vidas > 0) { if (vidas > 0) {
try_visible = TRUE; try_visible = TRUE;
printf ("Try again visible\n"); printf ("Try again visible\n");
@ -1801,7 +1827,7 @@ int game_loop (void) {
SDL_FreeSurface (vidas_p); SDL_FreeSurface (vidas_p);
snprintf (buffer, sizeof (buffer), "%d", vidas); snprintf (buffer, sizeof (buffer), "%d", vidas);
vidas_p = draw_text_with_shadow (ttf24_klickclack, 2, buffer, blanco, negro); vidas_p = draw_text_with_shadow (ttf24_klickclack, 2, buffer, blanco, negro);
/* TODO: Reproducir aquí el sonido de golpe */ if (use_sound) Mix_PlayChannel (-1, sounds[SND_TOONHIT], 0);
} else { } else {
gameover_visible = TRUE; gameover_visible = TRUE;
printf ("Game Over visible\n"); printf ("Game Over visible\n");
@ -1825,9 +1851,8 @@ int game_loop (void) {
if (i == SDL_TRUE) { if (i == SDL_TRUE) {
bags = 7; bags = 7;
/* TODO: Reproducir el sonido de golpe de yunque */
crash_anim = 0; crash_anim = 0;
if (use_sound) Mix_PlayChannel (-1, sounds[SND_TOONHIT], 0);
printf ("Penguin Crash by anvil\n"); printf ("Penguin Crash by anvil\n");
if (vidas > 0 && try_visible == FALSE) { if (vidas > 0 && try_visible == FALSE) {
try_visible = TRUE; try_visible = TRUE;
@ -1860,7 +1885,7 @@ int game_loop (void) {
SDL_FreeSurface (vidas_p); SDL_FreeSurface (vidas_p);
snprintf (buffer, sizeof (buffer), "%d", vidas); snprintf (buffer, sizeof (buffer), "%d", vidas);
vidas_p = draw_text_with_shadow (ttf24_klickclack, 2, buffer, blanco, negro); vidas_p = draw_text_with_shadow (ttf24_klickclack, 2, buffer, blanco, negro);
/* TODO: Reproducir sonido boing */ if (use_sound) Mix_PlayChannel (-1, sounds[SND_BOING], 0);
/* TODO: Mostrar la notificación de 1 vida */ /* TODO: Mostrar la notificación de 1 vida */
airbone--; airbone--;
@ -1876,7 +1901,7 @@ int game_loop (void) {
if (i == SDL_TRUE) { if (i == SDL_TRUE) {
bags = 8; bags = 8;
/* TODO: Reproducir el sonido de golpe de pescado */ if (use_sound) Mix_PlayChannel (-1, sounds[SND_TOONHIT], 0);
crash_anim = 0; crash_anim = 0;
if (vidas > 0 && try_visible == FALSE) { if (vidas > 0 && try_visible == FALSE) {
try_visible = TRUE; try_visible = TRUE;
@ -1903,7 +1928,7 @@ int game_loop (void) {
if (i == SDL_TRUE) { if (i == SDL_TRUE) {
bags = 9; bags = 9;
/* TODO: Reproducir el sonido de golpe de florero */ if (use_sound) Mix_PlayChannel (-1, sounds[SND_TOONHIT], 0);
crash_anim = 0; crash_anim = 0;
if (vidas > 0 && try_visible == FALSE) { if (vidas > 0 && try_visible == FALSE) {
@ -1929,16 +1954,20 @@ int game_loop (void) {
if (thisbag->bag <= 3 && j == 0) { if (thisbag->bag <= 3 && j == 0) {
/* Eliminar del airbone */ /* Eliminar del airbone */
airbone--; airbone--;
if (use_sound) Mix_PlayChannel (-1, sounds[SND_SPLOP], 0);
} else if (thisbag->bag == 5 && j == 0) { } else if (thisbag->bag == 5 && j == 0) {
/* Eliminar el yunque del airbone */ /* Eliminar el yunque del airbone */
airbone--; airbone--;
if (use_sound) Mix_PlayChannel (-1, sounds[SND_ANVIL], 0);
anvil_out = FALSE; anvil_out = FALSE;
} else if (thisbag->bag == 6 && j == 0) { } else if (thisbag->bag == 6 && j == 0) {
/* Eliminar el pescado del airbone */ /* Eliminar el pescado del airbone */
airbone--; airbone--;
if (use_sound) Mix_PlayChannel (-1, sounds[SND_FISH], 0);
fish_out = FALSE; fish_out = FALSE;
} else if (thisbag->bag == 7 && j == 0) { } else if (thisbag->bag == 7 && j == 0) {
airbone--; airbone--;
if (use_sound) Mix_PlayChannel (-1, sounds[SND_VASE], 0);
flower_out = FALSE; flower_out = FALSE;
} }
@ -2215,6 +2244,12 @@ int game_loop (void) {
} }
if (next_level_visible == NEXT_LEVEL) { if (next_level_visible == NEXT_LEVEL) {
if (animacion == 0) {
if (use_sound) Mix_PlayChannel (-1, sounds[SND_TRUCK], 0);
} else if (animacion == 56) {
if (use_sound) Mix_PlayChannel (-1, sounds[SND_TRUCK_REVERSE], 0);
}
if (animacion < 52) { if (animacion < 52) {
/* Presentar el texto del camión descargado */ /* Presentar el texto del camión descargado */
rect.w = texts[TEXT_UNLOADED]->w; rect.w = texts[TEXT_UNLOADED]->w;
@ -2425,7 +2460,7 @@ void setup (void) {
colliders_hazard_fish[9] = collider_new_block (11, 18); colliders_hazard_fish[9] = collider_new_block (11, 18);
if (use_sound) { if (use_sound) {
/*for (g = 0; g < NUM_SOUNDS; g++) { for (g = 0; g < NUM_SOUNDS; g++) {
sprintf (buffer_file, "%s%s", systemdata_path, sound_names[g]); sprintf (buffer_file, "%s%s", systemdata_path, sound_names[g]);
sounds[g] = Mix_LoadWAV (buffer_file); sounds[g] = Mix_LoadWAV (buffer_file);
@ -2439,7 +2474,7 @@ void setup (void) {
exit (1); exit (1);
} }
Mix_VolumeChunk (sounds[g], MIX_MAX_VOLUME / 2); Mix_VolumeChunk (sounds[g], MIX_MAX_VOLUME / 2);
}*/ }
/* Cargar la música */ /* Cargar la música */
//sprintf (buffer_file, "%s%s", systemdata_path, MUS_CARNIE); //sprintf (buffer_file, "%s%s", systemdata_path, MUS_CARNIE);