diff options
| author | 2019-10-30 00:38:04 -0400 | |
|---|---|---|
| committer | 2019-10-30 00:38:04 -0400 | |
| commit | 93902c57123c8e33f99263474eac726d4dbdceea (patch) | |
| tree | 5231712efba19bb089073dc26eba7855f0961a3d /frontends/sdl | |
| parent | dc41a8416c82925a2ac42b252ef00e35b18f55ed (diff) | |
| download | cetris-93902c57123c8e33f99263474eac726d4dbdceea.tar.gz cetris-93902c57123c8e33f99263474eac726d4dbdceea.tar.bz2 cetris-93902c57123c8e33f99263474eac726d4dbdceea.zip | |
random audio and tetris sound
Diffstat (limited to 'frontends/sdl')
| -rw-r--r-- | frontends/sdl/data/bclear_0.wav | bin | 0 -> 99828 bytes | |||
| -rw-r--r-- | frontends/sdl/data/bclear_1.wav | bin | 0 -> 89852 bytes | |||
| -rw-r--r-- | frontends/sdl/data/bclear_2.wav | bin | 0 -> 169676 bytes | |||
| -rw-r--r-- | frontends/sdl/data/bclear_3.wav | bin | 0 -> 129760 bytes | |||
| -rw-r--r-- | frontends/sdl/data/bclear_4.wav | bin | 0 -> 144728 bytes | |||
| -rw-r--r-- | frontends/sdl/data/tetris.wav | bin | 0 -> 142236 bytes | |||
| -rw-r--r-- | frontends/sdl/sdl_ui.c | 26 |
7 files changed, 21 insertions, 5 deletions
diff --git a/frontends/sdl/data/bclear_0.wav b/frontends/sdl/data/bclear_0.wav Binary files differnew file mode 100644 index 0000000..0d73145 --- /dev/null +++ b/frontends/sdl/data/bclear_0.wav diff --git a/frontends/sdl/data/bclear_1.wav b/frontends/sdl/data/bclear_1.wav Binary files differnew file mode 100644 index 0000000..674a778 --- /dev/null +++ b/frontends/sdl/data/bclear_1.wav diff --git a/frontends/sdl/data/bclear_2.wav b/frontends/sdl/data/bclear_2.wav Binary files differnew file mode 100644 index 0000000..10004ee --- /dev/null +++ b/frontends/sdl/data/bclear_2.wav diff --git a/frontends/sdl/data/bclear_3.wav b/frontends/sdl/data/bclear_3.wav Binary files differnew file mode 100644 index 0000000..cd5a390 --- /dev/null +++ b/frontends/sdl/data/bclear_3.wav diff --git a/frontends/sdl/data/bclear_4.wav b/frontends/sdl/data/bclear_4.wav Binary files differnew file mode 100644 index 0000000..38a2e10 --- /dev/null +++ b/frontends/sdl/data/bclear_4.wav diff --git a/frontends/sdl/data/tetris.wav b/frontends/sdl/data/tetris.wav Binary files differnew file mode 100644 index 0000000..aed36b9 --- /dev/null +++ b/frontends/sdl/data/tetris.wav 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); |