-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.cpp
44 lines (39 loc) · 929 Bytes
/
ui.cpp
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
#include "ui.h"
void init_ui()
{
setlocale(LC_ALL,"");
initscr();
nodelay(stdscr, TRUE);
noecho();
curs_set(0);
keypad(stdscr, TRUE);
start_color();
//init_pair(index,foreg,backg)
// BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE
init_pair(SNAKE_COLOR_PAIR, COLOR_BLUE, COLOR_BLACK);
init_pair(FOOD_COLOR_PAIR, COLOR_MAGENTA, COLOR_BLACK);
init_pair(BORDER_COLOR_PAIR, COLOR_WHITE, COLOR_BLACK);
init_pair(STATUS_COLOR_PAIR, COLOR_RED, COLOR_WHITE);
}
void tear_down_ui()
{
endwin();
}
void paint_border() {
attron(COLOR_PAIR(BORDER_COLOR_PAIR));
for(int i=0;i<COLS; i++)
{
move(0,i);
addstr("\u2588");
move(LINES-1,i);
addstr("\u2588");
}
for(int i=0;i<LINES; i++)
{
move(i, 0);
addstr("\u2588");
move(i, COLS-1);
addstr("\u2588");
}
attroff(COLOR_PAIR(BORDER_COLOR_PAIR));
}