diff --git a/README.md b/README.md index 8e8ee92..374e786 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,20 @@ Creating a Tetris clone in C to practice C programming and learn more about Rayl This game is a clone of the popular game Tetris. This clone features what you would expect from a simplistic version of Tetris, namely: falling blocks, which upon completion of a row disappear, score keeping and levels with incremental difficulty. +Here are some early screenshots of my progress: + +![gameplay](screenshots/game_screenshot.png "Gameplay") +![gameover](screenshots/game_over_screenshot.png "Game Over") + +Features left to-do: +- Update codebase to use cohesive style (still haven't landed on exactly what I like) +- Re-Implement rotation algorithm; my original algorithm was extremely buggy +- Empty rows that are full should "break" +- Broken rows should cause other rows to shift down without losing ordering +- scoring system +- display upcoming block +- introduce levels and increasing speed/score multiplier + I hope you enjoy! ## Getting Started diff --git a/TODO b/TODO deleted file mode 100644 index 110a117..0000000 --- a/TODO +++ /dev/null @@ -1,7 +0,0 @@ -- Re-organize manager.c to match manager.h, add internals to .h and fix code style to match rest of code -- Rotate (Partially Implemented/Buggy. Should try to understand Rotation Matrix better.) -- Empty rows that are full should "break" -- Shift rows down after row "breaks" -- Track and Display Score. During and After game -- display Upcoming block -- Introduce levels/speed up with every level \ No newline at end of file diff --git a/screenshots/game_over_screenshot.png b/screenshots/game_over_screenshot.png new file mode 100644 index 0000000..ff7dc52 Binary files /dev/null and b/screenshots/game_over_screenshot.png differ diff --git a/screenshots/game_screenshot.png b/screenshots/game_screenshot.png new file mode 100644 index 0000000..5bea28b Binary files /dev/null and b/screenshots/game_screenshot.png differ diff --git a/src/app.c b/src/app.c index 21510a6..9bfdbeb 100644 --- a/src/app.c +++ b/src/app.c @@ -8,17 +8,20 @@ #define TARGET_FPS 60 -void a_run(void) { - _a_initialize(); +int _a_tick_rate = 0; + +void a_run(int tick_rate) { + _a_initialize(tick_rate); _a_loop(); _a_cleanup(); } -void _a_initialize(void) { +void _a_initialize(int tick_rate) { _a_initialize_raylib(); m_initialize(); r_initialize(); _a_gameboard_clear(); + _a_tick_rate = tick_rate; } void _a_initialize_raylib(void) { @@ -35,23 +38,22 @@ void _a_gameboard_clear(void) { } void _a_loop(void) { - int tick_rate = 0; // Guaranteed a better way to do this XD + int tick_rate_counter = 0; while (!WindowShouldClose()) { - while (m_tetromino_can_spawn()) { - if (WindowShouldClose()) - return; + if (m_tetromino_can_spawn()) { _a_input_process(); - if (tick_rate == 0) { + if (tick_rate_counter == 0) { m_update(); - tick_rate = 50; + tick_rate_counter = _a_tick_rate; } int number_blocks_updated = 0; struct TetrominoBlock **blocks_updated = m_blocks_get_updated(&number_blocks_updated); r_render_blocks(blocks_updated, number_blocks_updated); - tick_rate--; + tick_rate_counter--; + } else { + r_render_game_over(0); } - r_render_game_over(0); } } diff --git a/src/app.h b/src/app.h index 2376cc1..0b1ad81 100644 --- a/src/app.h +++ b/src/app.h @@ -1,9 +1,9 @@ #ifndef TETRIS_CLONE_APP_H_ #define TETRIS_CLONE_APP_H_ -void a_run(void); +void a_run(int tick_rate); -void _a_initialize(void); +void _a_initialize(int tick_rate); void _a_initialize_raylib(void); void _a_gameboard_clear(void); void _a_loop(void); diff --git a/src/main.c b/src/main.c index 7952e2e..2106f58 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,18 @@ #include "app.h" +#include +#include +#include -int main(void) { - a_run(); +int main(int argc, char **argv) { + // Not great code if I were to need multiple options, but I just need to be + // able to debug + if (argc > 1) { + if (strcmp(argv[1], "--speed") == 0) { + a_run(atoi(argv[2])); + } + } else { + a_run(50); + } return 0; }