summaryrefslogtreecommitdiff
path: root/sirtet.c
diff options
context:
space:
mode:
Diffstat (limited to 'sirtet.c')
-rw-r--r--sirtet.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/sirtet.c b/sirtet.c
index 79685ae..b3945fb 100644
--- a/sirtet.c
+++ b/sirtet.c
@@ -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();