diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-06-06 12:36:14 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-06-06 12:36:14 +0800 |
commit | e5711dbe6dc7f38314971e154b57f49450e68a7c (patch) | |
tree | ef085c6ad29e2067c428bf5c71bfd1947fa33553 /sirtet.c | |
parent | 5c43e5da6e3768b9c734fbd6a4a4b824f953d842 (diff) |
Diffstat (limited to 'sirtet.c')
-rw-r--r-- | sirtet.c | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -9,12 +9,6 @@ #include "ui.h" #include "util.h" -void clearmap(char* map, int mapH, int mapW) { - for (int b = 0; b < mapH * mapW; b++) { - map[b] = ' '; - } -} - struct clearfull_data { int rows; int cols; @@ -75,12 +69,16 @@ void sirtet(int H, int W, int P) { if (map == NULL) mallocfail(); + for (int b = 0; b < H * W; b++) { + // fill map with blank blocks + map[b] = ' '; + } + struct piece** hand = malloc(P * sizeof(struct piece*)); if (hand == NULL) mallocfail(); srand(time(NULL)); - clearmap(map, H, W); refillpieces(hand, P); bool over = false; @@ -106,13 +104,7 @@ void sirtet(int H, int W, int P) { printrect(0, 0, H, W); printmap(map, 1, 1, H, W); printhelp(4, 2 * W + 8); - - // display game stats - mvprintw(1, 2 * W + 8, "Points: %d", points); - if (combo) - mvprintw(2, 2 * W + 8, "Combo: %d", combo); - - refresh(); + printstats(points, combo, 1, 2 * W + 8); // select piece and position bool confirmed = false; @@ -247,6 +239,7 @@ void sirtet(int H, int W, int P) { if (!has_placeable) { // game over printmap(map, 1, 1, H, W); + printstats(points, combo, 1, 2 * W + 8); mvprintw(8, 2 * W + 8, "Game over"); mvprintw(9, 2 * W + 8, "Press any key to exit"); refresh(); |