-
Notifications
You must be signed in to change notification settings - Fork 1
/
tetris.c
71 lines (58 loc) · 2.07 KB
/
tetris.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "tetris.h"
int main(void) {
WINDOW * mainwin;
/* Initialize ncurses */
if ((mainwin = initscr()) == NULL) {
fprintf(stderr, "Error initialising ncurses.\n");
exit(EXIT_FAILURE);
}
printGrid();
refresh();
sleep(30);
delwin(mainwin);
endwin();
refresh();
return EXIT_SUCCESS;
}
void printGrid() {
int i;
// Empty Grid
for(i = GRID_START; i <= GRID_HEIGHT; i++) {
switch(i) {
case GRID_START:
mvaddstr(i, 0, " _________________________ __________________________________________________ _________________________");
break;
case GRID_HEIGHT:
mvaddstr(i, 0, "|_________________________||__________________________________________________||_________________________|");
break;
default:
mvaddstr(i, 0, "| || || |");
break;
}
}
// Score
mvaddstr(SCORE_X, SCORE_Y, ",-. ,-. ,-. ,-. ,-.");
mvaddstr(SCORE_X + 1, SCORE_Y, "`-. | | | | |-' ::");
mvaddstr(SCORE_X + 2, SCORE_Y, "`-' `-' `-' ' `-'");
// Hold
mvaddstr(HOLD_X, HOLD_Y, ". . .");
mvaddstr(HOLD_X + 1, HOLD_Y, "|-. ,-. | ,-|");
mvaddstr(HOLD_X + 2, HOLD_Y, "| | | | | | |");
mvaddstr(HOLD_X + 3, HOLD_Y, "' ' `-' `' `-'");
// Level
mvaddstr(LEVEL_X, HOLD_Y, ". .");
mvaddstr(LEVEL_X + 1, HOLD_Y, "| ,-. . , ,-. |");
mvaddstr(LEVEL_X + 2, HOLD_Y, "| |-' | / |-' |");
mvaddstr(LEVEL_X + 3, HOLD_Y, "`' `-' `' `-' `'");
// Goal
mvaddstr(GOAL_X, GOAL_Y, " .");
mvaddstr(GOAL_X + 1, GOAL_Y, ",-. ,-. ,-. |");
mvaddstr(GOAL_X + 2, GOAL_Y, "| | | | ,-| |");
mvaddstr(GOAL_X + 3, GOAL_Y, "`-| `-' `-^ `'");
mvaddstr(GOAL_X + 4, GOAL_Y, " ,|");
mvaddstr(GOAL_X + 5, GOAL_Y, " `'");
// Next
mvaddstr(NEXT_X, NEXT_Y, ",-. ,-. . , |-");
mvaddstr(NEXT_X + 1, NEXT_Y, "| | |-' X |");
mvaddstr(NEXT_X + 2, NEXT_Y, "' ' `-' ' ` `'");
}