-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.c
120 lines (96 loc) · 2.96 KB
/
system.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include"system.h"
void welcome(int x, int y){
mvprintw(y, x, " ____ ____ ______ _ ____ ____ __ __ ____ ____ ____ ______ __ __ ");
mvprintw(++y, x, " / || \\ | | | | / || \\ | | || \\ | || \\ | || | |");
mvprintw(++y, x, "| o || _ || | | | | o || o )| | || D ) | | | _ || || | |");
mvprintw(++y, x, "| || | ||_| |_| | |___ | || || ~ || / | | | | ||_| |_|| _ |");
mvprintw(++y, x, "| _ || | | | | | || _ || O ||___, || \\ | | | | | | | | | |");
mvprintw(++y, x, "| | || | | | | | || | || || || . \\ | | | | | | | | | |");
mvprintw(++y, x, "|__|__||__|__| |__| |_____||__|__||_____||____/ |__|\\_||____||__|__| |__| |__|__|");
mvprintw(++y, 0, "\n");
mvprintw(++y, 0, "\n");
for(int k=++y; k <= 101; k++){
attron(COLOR_PAIR(3));
mvprintw(y, k, " |");
mvprintw(y+1, k, " |.===.");
mvprintw(y+2, k, " {}o o{}");
mvprintw(y+3, k, " O--(_)--O");
attroff(COLOR_PAIR(3));
refresh();
usleep(15000);
}
attron(COLOR_PAIR(2));
mvprintw(y+3, 113, "z1ron@2018");
attroff(COLOR_PAIR(2));
}
int menu(WINDOW *win, char **choiches){
int highlight = 0, choice;
while(1){
for(int i=0; i < 3; i++){
if(i == highlight)
wattron(win, A_REVERSE);
mvwprintw(win, i+1, 1, choiches[i]);
wattroff(win, A_REVERSE);
}
choice = wgetch(win);
switch(choice){
case KEY_UP:
highlight--;
if(highlight < 0)
highlight = 2;
break;
case KEY_DOWN:
highlight++;
if(highlight > 2)
highlight = 0;
break;
default:
break;
}
if(choice == 10)
break;
}
return highlight;
}
int verifyPoint(Point *p){ // verifica se o ponto esta na pilha
Point *temp = ps;
int b = 0; // bool
while(temp != NULL){
if(temp->x == p->x && temp->y == p->y){
b = 1;
break;
}
temp = temp->prox;
}
return b;
}
void Print(WINDOW *win, Point *p){
int k = 0;
mvwprintw(win, 14, 2,"Caminho:\n\t");
while(p != NULL){
k += 7;
mvwprintw(win, 16, k,"(%d,%d) ",p->x,p->y);
p = p->prox;
}
wprintw(win, "\n");
}
Point *init(Point *p){
p = (Point *) malloc(sizeof(Point));
p->x = p->y = 0;
p->prox = NULL;
return p;
}
void savePoint(Point *p){ // push
Point *aux = (Point *) malloc(sizeof(Point));
aux->prox = ps;
aux->x = p->x;
aux->y = p->y;
ps = aux;
}
Point loadPoint(){
//remove point
Point *aux = ps;
ps = ps->prox;
free(aux);
return *ps;
}