summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontends/sdl/data/clear_0.wavbin0 -> 48164 bytes
-rw-r--r--frontends/sdl/data/clear_1.wavbin0 -> 48164 bytes
-rw-r--r--frontends/sdl/data/clear_2.wavbin0 -> 48164 bytes
-rw-r--r--frontends/sdl/data/clear_3.wavbin0 -> 48164 bytes
-rw-r--r--frontends/sdl/data/lock.wavbin0 -> 8864 bytes
-rw-r--r--frontends/sdl/data/yea_0.wavbin212984 -> 0 bytes
-rw-r--r--frontends/sdl/data/yea_1.wavbin212984 -> 0 bytes
-rw-r--r--frontends/sdl/data/yea_2.wavbin212984 -> 0 bytes
-rw-r--r--frontends/sdl/data/yea_3.wavbin425912 -> 0 bytes
-rw-r--r--frontends/sdl/sdl_ui.c35
m---------ini0
-rw-r--r--lib/cetris.c3
-rw-r--r--lib/cetris.h5
-rw-r--r--lib/rules.c3
-rwxr-xr-xtest/a.outbin16712 -> 0 bytes
15 files changed, 31 insertions, 15 deletions
diff --git a/frontends/sdl/data/clear_0.wav b/frontends/sdl/data/clear_0.wav
new file mode 100644
index 0000000..2f36c53
--- /dev/null
+++ b/frontends/sdl/data/clear_0.wav
Binary files differ
diff --git a/frontends/sdl/data/clear_1.wav b/frontends/sdl/data/clear_1.wav
new file mode 100644
index 0000000..7475e51
--- /dev/null
+++ b/frontends/sdl/data/clear_1.wav
Binary files differ
diff --git a/frontends/sdl/data/clear_2.wav b/frontends/sdl/data/clear_2.wav
new file mode 100644
index 0000000..9e9eb3e
--- /dev/null
+++ b/frontends/sdl/data/clear_2.wav
Binary files differ
diff --git a/frontends/sdl/data/clear_3.wav b/frontends/sdl/data/clear_3.wav
new file mode 100644
index 0000000..f299513
--- /dev/null
+++ b/frontends/sdl/data/clear_3.wav
Binary files differ
diff --git a/frontends/sdl/data/lock.wav b/frontends/sdl/data/lock.wav
new file mode 100644
index 0000000..6229891
--- /dev/null
+++ b/frontends/sdl/data/lock.wav
Binary files differ
diff --git a/frontends/sdl/data/yea_0.wav b/frontends/sdl/data/yea_0.wav
deleted file mode 100644
index 6fa9fdf..0000000
--- a/frontends/sdl/data/yea_0.wav
+++ /dev/null
Binary files differ
diff --git a/frontends/sdl/data/yea_1.wav b/frontends/sdl/data/yea_1.wav
deleted file mode 100644
index 3c795ec..0000000
--- a/frontends/sdl/data/yea_1.wav
+++ /dev/null
Binary files differ
diff --git a/frontends/sdl/data/yea_2.wav b/frontends/sdl/data/yea_2.wav
deleted file mode 100644
index 67511b9..0000000
--- a/frontends/sdl/data/yea_2.wav
+++ /dev/null
Binary files differ
diff --git a/frontends/sdl/data/yea_3.wav b/frontends/sdl/data/yea_3.wav
deleted file mode 100644
index 4098797..0000000
--- a/frontends/sdl/data/yea_3.wav
+++ /dev/null
Binary files 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);
diff --git a/ini b/ini
-Subproject bd808a59cdd6c1dc56cedf6fbc0e750680ce270
+Subproject 9b15f721fd53b1beb8364f8763e2207963ac4fd
diff --git a/lib/cetris.c b/lib/cetris.c
index 3bff1f1..ffffd2a 100644
--- a/lib/cetris.c
+++ b/lib/cetris.c
@@ -212,7 +212,6 @@ static void next_piece(cetris_game *g) {
}
static void lock_current(cetris_game *g) {
- g->current.locked = true;
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 4; x++) {
if ((g->current.m[y]>>(3 - x))&1) {
@@ -226,6 +225,8 @@ static void lock_current(cetris_game *g) {
g->highest_line = g->current.pos.y;
}
+ g->current.locked = true;
+ g->lock_event = true;
update_board(g);
}
diff --git a/lib/cetris.h b/lib/cetris.h
index 3a71999..22723b0 100644
--- a/lib/cetris.h
+++ b/lib/cetris.h
@@ -141,9 +141,12 @@ struct cetris_game {
uint8_t level;
uint8_t lines;
uint8_t line_combo;
- bool line_event;
bool game_over;
+ // events
+ bool line_event;
+ bool lock_event;
+
// scoring flags
bool tspin;
bool mini_tspin;
diff --git a/lib/rules.c b/lib/rules.c
index ce06d83..a905b79 100644
--- a/lib/rules.c
+++ b/lib/rules.c
@@ -1,3 +1,5 @@
+// collection of win conditions, rulesets, and gameplay settings from various tetris games
+
#include <cetris.h>
#include <rules.h>
@@ -15,6 +17,7 @@ bool marathon(cetris_game *g) {
return false;
}
+// https://tetris.fandom.com/wiki/Tetris_DS
cetris_config tetris_ds_config = {
.board_x = 10,
.board_y = 43,
diff --git a/test/a.out b/test/a.out
deleted file mode 100755
index bd6f439..0000000
--- a/test/a.out
+++ /dev/null
Binary files differ