summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-03-04 19:31:19 -0500
committerAndrew Opalach <andrew@akon.city> 2019-03-04 19:31:19 -0500
commit3be83e5f03748a6e7d9db785e38346ec45c69a35 (patch)
tree15fc9f205ad10599fba17a93cc0e501b3b46b37b /frontend
parent7c737f4d1d21a8c666bc8b868f4f29cfe9a3cbab (diff)
downloadcetris-3be83e5f03748a6e7d9db785e38346ec45c69a35.tar.gz
cetris-3be83e5f03748a6e7d9db785e38346ec45c69a35.tar.bz2
cetris-3be83e5f03748a6e7d9db785e38346ec45c69a35.zip
add scoring and fix some timing
Diffstat (limited to 'frontend')
-rw-r--r--frontend/ncurses/ncurses_ui.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/frontend/ncurses/ncurses_ui.c b/frontend/ncurses/ncurses_ui.c
index 1ae07b2..71ef49f 100644
--- a/frontend/ncurses/ncurses_ui.c
+++ b/frontend/ncurses/ncurses_ui.c
@@ -1,31 +1,32 @@
#include <stdlib.h>
+#include <string.h>
#include <ncurses.h>
#include <locale.h>
#include "cetris.h"
#define BLOCK "[]"
-#define PLAY_FIELD_STR " /--------------------\\ /--------\\\n"\
- " | | | |\n"\
- " | | \\--------/\n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
- " | | \n"\
+#define PLAY_FIELD_STR " /--------------------\\ /----------------\\\n"\
+ " | | | |\n"\
+ " | | \\----------------/\n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
+ " | | \n"\
" \\--------------------/"
#define X_OFFSET 8
@@ -56,7 +57,7 @@ void draw_board(struct cetris_game* g) {
for (int x = 0; x < BOARD_X; x++) {
for (int y = 0; y < BOARD_Y; y++) {
if (g->board[x][y].occupied) {
- attron(COLOR_PAIR(g->board[x][y].c));
+ attron(COLOR_PAIR(g->board[x][y].c));
if (g->board[x][y].remove_tick > 0) {
if (g->tick % 2 == 0) {
mvaddstr(y + 1, x * 2 + X_OFFSET, BLOCK);
@@ -64,9 +65,12 @@ void draw_board(struct cetris_game* g) {
} else {
mvaddstr(y + 1, x * 2 + X_OFFSET, BLOCK);
}
- attroff(COLOR_PAIR(g->board[x][y].c));
+ attroff(COLOR_PAIR(g->board[x][y].c));
}
}
+ char score[50];
+ sprintf(score, "%li", g->score);
+ mvaddstr(1, (41 + X_OFFSET) - strlen(score), score);
}
}