README.md updates and speed option for testing
This commit is contained in:
14
README.md
14
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:
|
||||
|
||||

|
||||

|
||||
|
||||
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
|
||||
|
||||
7
TODO
7
TODO
@@ -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
|
||||
BIN
screenshots/game_over_screenshot.png
Normal file
BIN
screenshots/game_over_screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
BIN
screenshots/game_screenshot.png
Normal file
BIN
screenshots/game_screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
24
src/app.c
24
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,24 +38,23 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _a_input_process(void) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
15
src/main.c
15
src/main.c
@@ -1,7 +1,18 @@
|
||||
#include "app.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user