jag

tetoris_c

public

Small block game in C

Star0
Watch0

Commit 4d762544db0f

tarball

Jaglekon <58274093+Jaglekon@users.noreply.github.com>2026-08-03 21:13 UTC

5 files changed+27-14
icons
Modified file: source/main.c+24 additions−12 deletions
@@ -353,23 +353,35 @@ int main () {
353353 /* Looks for cleared line */
354354
355355 int8_t j, k;
356+
357+ {
358+
359+ uint8_t current_lines = 0;
360+
361+ for (j = FIELD_HEIGHT - 1; j >= 0; j--) {
362+
363+ uint8_t blocked = 0;
356364
357- for (j = FIELD_HEIGHT - 1; j >= 0; j--) {
358365
359- uint8_t blocked = 0;
366+ for (k = 0; k < FIELD_WIDTH; k++) {
367+ if (playfield[j][k + BORDER_WIDTH] != EMPTY)
368+ blocked++;
369+ }
360370
361- for (k = 0; k < FIELD_WIDTH; k++) {
362- if (playfield[j][k + BORDER_WIDTH] != EMPTY)
363- blocked++;
371+ if (blocked == 10) {
372+
373+ blink[j] = true;
374+ is_tetris = true;
375+ lines_to_level++;
376+ current_lines++;
377+ } else {
378+ blink[j] = false;
379+ }
364380 }
365381
366- if (blocked == 10) {
367-
368- blink[j] = true;
369- is_tetris = true;
370- lines_to_level++;
371- } else {
372- blink[j] = false;
382+ if (current_lines > 0) {
383+ pot_score_lines += line_points_add(current_lines, level);
384+ add_score = true;
373385 }
374386 }
375387
Binary file: source/main.obinary

Binary file not shown.

Modified file: source/parser.c+2 additions−2 deletions
@@ -101,6 +101,6 @@ keypress parse_input() {
101101 }
102102
103103 void break_unfinished() {
104- length--;
105- start = next_pos(start);
104+ while (length--)
105+ start = next_pos(start);
106106 }
Modified file: source/parser.h+1 additions
@@ -4,6 +4,7 @@
44 #include <string.h>
55 #include <ctype.h>
66 #include <stdint.h>
7+#include <stdbool.h>
78
89 #define BUF_LEN 4096
910 #define ARROW_LEN 3
Binary file: source/parser.obinary

Binary file not shown.