From 0a96dc5bd5d13b250e11e80d3ed260b74b85c548 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 29 Oct 2019 16:52:55 -0400 Subject: change up sounds and add lock_event --- frontends/sdl/data/clear_0.wav | Bin 0 -> 48164 bytes frontends/sdl/data/clear_1.wav | Bin 0 -> 48164 bytes frontends/sdl/data/clear_2.wav | Bin 0 -> 48164 bytes frontends/sdl/data/clear_3.wav | Bin 0 -> 48164 bytes frontends/sdl/data/lock.wav | Bin 0 -> 8864 bytes frontends/sdl/data/yea_0.wav | Bin 212984 -> 0 bytes frontends/sdl/data/yea_1.wav | Bin 212984 -> 0 bytes frontends/sdl/data/yea_2.wav | Bin 212984 -> 0 bytes frontends/sdl/data/yea_3.wav | Bin 425912 -> 0 bytes frontends/sdl/sdl_ui.c | 35 ++++++++++++++++++++++------------- 10 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 frontends/sdl/data/clear_0.wav create mode 100644 frontends/sdl/data/clear_1.wav create mode 100644 frontends/sdl/data/clear_2.wav create mode 100644 frontends/sdl/data/clear_3.wav create mode 100644 frontends/sdl/data/lock.wav delete mode 100644 frontends/sdl/data/yea_0.wav delete mode 100644 frontends/sdl/data/yea_1.wav delete mode 100644 frontends/sdl/data/yea_2.wav delete mode 100644 frontends/sdl/data/yea_3.wav (limited to 'frontends') diff --git a/frontends/sdl/data/clear_0.wav b/frontends/sdl/data/clear_0.wav new file mode 100644 index 0000000..2f36c53 Binary files /dev/null and b/frontends/sdl/data/clear_0.wav differ diff --git a/frontends/sdl/data/clear_1.wav b/frontends/sdl/data/clear_1.wav new file mode 100644 index 0000000..7475e51 Binary files /dev/null and b/frontends/sdl/data/clear_1.wav differ diff --git a/frontends/sdl/data/clear_2.wav b/frontends/sdl/data/clear_2.wav new file mode 100644 index 0000000..9e9eb3e Binary files /dev/null and b/frontends/sdl/data/clear_2.wav differ diff --git a/frontends/sdl/data/clear_3.wav b/frontends/sdl/data/clear_3.wav new file mode 100644 index 0000000..f299513 Binary files /dev/null and b/frontends/sdl/data/clear_3.wav differ diff --git a/frontends/sdl/data/lock.wav b/frontends/sdl/data/lock.wav new file mode 100644 index 0000000..6229891 Binary files /dev/null and b/frontends/sdl/data/lock.wav differ diff --git a/frontends/sdl/data/yea_0.wav b/frontends/sdl/data/yea_0.wav deleted file mode 100644 index 6fa9fdf..0000000 Binary files a/frontends/sdl/data/yea_0.wav and /dev/null differ diff --git a/frontends/sdl/data/yea_1.wav b/frontends/sdl/data/yea_1.wav deleted file mode 100644 index 3c795ec..0000000 Binary files a/frontends/sdl/data/yea_1.wav and /dev/null differ diff --git a/frontends/sdl/data/yea_2.wav b/frontends/sdl/data/yea_2.wav deleted file mode 100644 index 67511b9..0000000 Binary files a/frontends/sdl/data/yea_2.wav and /dev/null differ diff --git a/frontends/sdl/data/yea_3.wav b/frontends/sdl/data/yea_3.wav deleted file mode 100644 index 4098797..0000000 Binary files a/frontends/sdl/data/yea_3.wav and /dev/null differ diff --git a/frontends/sdl/sdl_ui.c b/frontends/sdl/sdl_ui.c index 6b817f3..c8c90e8 100644 --- a/frontends/sdl/sdl_ui.c +++ b/frontends/sdl/sdl_ui.c @@ -36,6 +36,7 @@ int font_count; font_t fonts[10]; audio_clip_t clear_sound[4]; +audio_clip_t lock_sound; SDL_AudioDeviceID audio_device; void setup_sdl() { @@ -51,9 +52,10 @@ void setup_sdl() { for (int i = 0; i < 4; i++) { char name[25]; - sprintf(name, "data/yea_%i.wav", i); + sprintf(name, "data/clear_%i.wav", i); SDL_LoadWAV(name, &(clear_sound[i].wav_spec), &(clear_sound[i].wav_buffer), &(clear_sound[i].wav_length)); } + SDL_LoadWAV("data/lock.wav", &(lock_sound.wav_spec), &(lock_sound.wav_buffer), &(lock_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"); } @@ -113,8 +115,8 @@ void draw_board(game_board_t* board, int x, int y, int w, int h) { int board_y = board->game->config.board_y; int board_visible = board_y - board->game->config.board_visible; - float block_width = w / board->game->config.board_x; - float block_height = h / board->game->config.board_visible; + int block_width = w / board->game->config.board_x; + int block_height = h / board->game->config.board_visible; for (int s = 0; s < board_x + 1; s++) { int rx = x + (s * block_width); @@ -170,13 +172,13 @@ void draw_board(game_board_t* board, int x, int y, int w, int h) { } void draw_held_piece(game_board_t* board, int x, int y, int w, int h) { - float block_width = w / 4; - float block_height = h / 4; + int block_width = w / 4; + int block_height = h / 4; SDL_Rect hold = {x, y, w + 1, h}; - SDL_SetRenderDrawColor(render, board->scheme.main.r, - board->scheme.main.g, board->scheme.main.b, board->scheme.main.a); + SDL_SetRenderDrawColor(render, board->scheme.off.r, + board->scheme.off.g, board->scheme.off.b, board->scheme.off.a); SDL_RenderFillRect(render, &hold); SDL_RenderDrawRect(render, &hold); @@ -185,7 +187,7 @@ void draw_held_piece(game_board_t* board, int x, int y, int w, int h) { for (int s = 0; s < 4; s++) { for (int j = 0; j < 4; j++) { if ((board->game->held.m[s]>>(3 - j))&1) { - float block_x = x + (j * block_width) + (block_width / 2.0); + int block_x = x + (j * block_width) + (block_width / 2.0); int block_y = y + (s * block_height); if (board->game->held.t == MINO_I) { block_x -= block_width / 2; @@ -205,11 +207,11 @@ void draw_held_piece(game_board_t* board, int x, int y, int w, int h) { } void draw_piece_queue(game_board_t* board, int x, int y, int w, int h) { - float block_width = (w / 4); - float block_height = h / 15; + int block_width = (w / 4); + int block_height = h / 15; - SDL_SetRenderDrawColor(render, board->scheme.main.r, - board->scheme.main.g, board->scheme.main.b, board->scheme.main.a); + SDL_SetRenderDrawColor(render, board->scheme.off.r, + board->scheme.off.g, board->scheme.off.b, board->scheme.off.a); SDL_Rect queue = {x, y, w + 1, h}; SDL_RenderFillRect(render, &queue); @@ -230,7 +232,7 @@ void draw_piece_queue(game_board_t* board, int x, int y, int w, int h) { for (int j = 0; j < 4; j++) { if ((default_matrices[mino][s]>>(3 - j))&1) { - float block_x = x + (j) * block_width + (block_width / 2.0); + int block_x = x + (j) * block_width + (block_width / 2.0); int block_y = y + ((i * 3) + s) * block_height; if (mino == MINO_I) { block_x -= block_width / 2; @@ -408,6 +410,13 @@ int main(void) { int success = SDL_QueueAudio(audio_device, clear_sound[index].wav_buffer, clear_sound[index].wav_length); SDL_PauseAudioDevice(audio_device, 0); g.line_event = false; + g.lock_event = false; + } + + if (g.lock_event) { + int success = SDL_QueueAudio(audio_device, lock_sound.wav_buffer, lock_sound.wav_length); + SDL_PauseAudioDevice(audio_device, 0); + g.lock_event = false; } SDL_Delay(1000 / FRAME_RATE); -- cgit v1.2.3-101-g0448