From 93902c57123c8e33f99263474eac726d4dbdceea Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 30 Oct 2019 00:38:04 -0400 Subject: random audio and tetris sound --- 55c76847caa311c7caad17a66beb31a.jpg-autosave.kra | Bin 0 -> 2066257 bytes ...is Arle & Carbuncle Voice Clips-kaFocY5yBmY.m4a | Bin 0 -> 1475540 bytes frontends/sdl/data/bclear_0.wav | Bin 0 -> 99828 bytes frontends/sdl/data/bclear_1.wav | Bin 0 -> 89852 bytes frontends/sdl/data/bclear_2.wav | Bin 0 -> 169676 bytes frontends/sdl/data/bclear_3.wav | Bin 0 -> 129760 bytes frontends/sdl/data/bclear_4.wav | Bin 0 -> 144728 bytes frontends/sdl/data/tetris.wav | Bin 0 -> 142236 bytes frontends/sdl/sdl_ui.c | 26 +++++++++++++++++---- ini | 2 +- lib/cetris.c | 6 ++++- lib/cetris.h | 1 + 12 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 55c76847caa311c7caad17a66beb31a.jpg-autosave.kra create mode 100644 Puyo Puyo Tetris Arle & Carbuncle Voice Clips-kaFocY5yBmY.m4a create mode 100644 frontends/sdl/data/bclear_0.wav create mode 100644 frontends/sdl/data/bclear_1.wav create mode 100644 frontends/sdl/data/bclear_2.wav create mode 100644 frontends/sdl/data/bclear_3.wav create mode 100644 frontends/sdl/data/bclear_4.wav create mode 100644 frontends/sdl/data/tetris.wav diff --git a/55c76847caa311c7caad17a66beb31a.jpg-autosave.kra b/55c76847caa311c7caad17a66beb31a.jpg-autosave.kra new file mode 100644 index 0000000..9992e99 Binary files /dev/null and b/55c76847caa311c7caad17a66beb31a.jpg-autosave.kra differ diff --git a/Puyo Puyo Tetris Arle & Carbuncle Voice Clips-kaFocY5yBmY.m4a b/Puyo Puyo Tetris Arle & Carbuncle Voice Clips-kaFocY5yBmY.m4a new file mode 100644 index 0000000..f8497f4 Binary files /dev/null and b/Puyo Puyo Tetris Arle & Carbuncle Voice Clips-kaFocY5yBmY.m4a differ diff --git a/frontends/sdl/data/bclear_0.wav b/frontends/sdl/data/bclear_0.wav new file mode 100644 index 0000000..0d73145 Binary files /dev/null and b/frontends/sdl/data/bclear_0.wav differ diff --git a/frontends/sdl/data/bclear_1.wav b/frontends/sdl/data/bclear_1.wav new file mode 100644 index 0000000..674a778 Binary files /dev/null and b/frontends/sdl/data/bclear_1.wav differ diff --git a/frontends/sdl/data/bclear_2.wav b/frontends/sdl/data/bclear_2.wav new file mode 100644 index 0000000..10004ee Binary files /dev/null and b/frontends/sdl/data/bclear_2.wav differ diff --git a/frontends/sdl/data/bclear_3.wav b/frontends/sdl/data/bclear_3.wav new file mode 100644 index 0000000..cd5a390 Binary files /dev/null and b/frontends/sdl/data/bclear_3.wav differ diff --git a/frontends/sdl/data/bclear_4.wav b/frontends/sdl/data/bclear_4.wav new file mode 100644 index 0000000..38a2e10 Binary files /dev/null and b/frontends/sdl/data/bclear_4.wav differ diff --git a/frontends/sdl/data/tetris.wav b/frontends/sdl/data/tetris.wav new file mode 100644 index 0000000..aed36b9 Binary files /dev/null and b/frontends/sdl/data/tetris.wav differ diff --git a/frontends/sdl/sdl_ui.c b/frontends/sdl/sdl_ui.c index 5fa374c..51c1497 100644 --- a/frontends/sdl/sdl_ui.c +++ b/frontends/sdl/sdl_ui.c @@ -39,8 +39,10 @@ game_board_t main_board; int font_count; font_t fonts[10]; -audio_clip_t clear_sound[4]; +bool random_audio; +audio_clip_t clear_sound[5]; audio_clip_t lock_sound; +audio_clip_t tetris_sound; SDL_AudioDeviceID audio_device; void setup_sdl() { @@ -56,15 +58,16 @@ void setup_sdl() { TTF_Init(); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 5; i++) { char name[25]; - format_str(name, 25, "data/clear_%i.wav", i); + format_str(name, 25, "data/bclear_%i.wav", i); SDL_LoadWAV(name, &(clear_sound[i].wav_spec), &(clear_sound[i].wav_buffer), &(clear_sound[i].wav_length)); } IMG_Init(IMG_INIT_PNG); SDL_LoadWAV("data/lock.wav", &(lock_sound.wav_spec), &(lock_sound.wav_buffer), &(lock_sound.wav_length)); + SDL_LoadWAV("data/tetris.wav", &(tetris_sound.wav_spec), &(tetris_sound.wav_buffer), &(tetris_sound.wav_length)); audio_device = SDL_OpenAudioDevice(NULL, 0, &(clear_sound[0].wav_spec), NULL, 0); if (audio_device == 0) printf("failed to open audio device\n"); } @@ -420,6 +423,8 @@ int main(void) { main_board.count_down = 3; init_game(&g, &config); main_board.game = &g; + + random_audio = true; SDL_Event e; for(;;) { @@ -479,8 +484,13 @@ int main(void) { } if (g.line_event > 0) { - int index = g.line_combo - 1; - if (index > 3) index = 3; + int index; + if (!random_audio) { + index = g.line_combo - 1; + if (index > 3) index = 3; + } else { + index = rand() % 5; + } int success = SDL_QueueAudio(audio_device, clear_sound[index].wav_buffer, clear_sound[index].wav_length); SDL_PauseAudioDevice(audio_device, 0); g.line_event--; @@ -489,6 +499,12 @@ int main(void) { } } + if (g.tetris_event > 0) { + int success = SDL_QueueAudio(audio_device, tetris_sound.wav_buffer, tetris_sound.wav_length); + SDL_PauseAudioDevice(audio_device, 0); + g.tetris_event--; + } + if (g.lock_event > 0) { int success = SDL_QueueAudio(audio_device, lock_sound.wav_buffer, lock_sound.wav_length); SDL_PauseAudioDevice(audio_device, 0); diff --git a/ini b/ini index 3401f2e..9b15f72 160000 --- a/ini +++ b/ini @@ -1 +1 @@ -Subproject commit 3401f2ed3153c6093c2f434e205cf6e7775a02d5 +Subproject commit 9b15f721fd53b1beb8364f8763e2207963ac4fd6 diff --git a/lib/cetris.c b/lib/cetris.c index e2acdec..35d92e3 100644 --- a/lib/cetris.c +++ b/lib/cetris.c @@ -393,8 +393,12 @@ void update_board(cetris_game *g) { g->lines += lines_cleared; if (lines_cleared > 0) { + if (lines_cleared == 4) { + g->tetris_event++; + } else { + g->line_event++; + } g->line_combo++; - g->line_event++; } if (g->lines >= (g->level * 10)) { g->level++; diff --git a/lib/cetris.h b/lib/cetris.h index 435a98d..523b867 100644 --- a/lib/cetris.h +++ b/lib/cetris.h @@ -146,6 +146,7 @@ struct cetris_game { // events uint8_t line_event; uint8_t lock_event; + uint8_t tetris_event; // scoring flags bool tspin; -- cgit v1.2.3-101-g0448