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
|
#include <ncurses.h>
#include <stdlib.h>
#include <time.h>
#include "server.c"
#define height 80
#define width 200
struct p {
int x;
int y;
};
struct p rP() {
struct p p;
p.x = (rand() % (width - 2)) + 1;
if (p.x%2 == 0) {
} else {
p.x++;
}
p.y = (rand() % (height - 2)) + 1;
return p;
}
struct items {
int len;
char items[3][15];
};
int menu(int y, int x, int h, int w, int aLen, char it[][15])
{
int key, i, c = 0, o = 0;
WINDOW * menu = newwin(h, w, y, x);
refresh();
box(menu, 0, 0);
while(o == 0)
{
for(i = 0; i < aLen; ++i) {
if(i == c) {
wattron(menu, A_STANDOUT);
mvwprintw(menu, i + 1, 1, "%s", it[i]);
wattroff(menu, A_STANDOUT);
} else {
mvwprintw(menu, i + 1, 1, "%s", it[i]);
}
}
switch(key = wgetch(menu))
{
case 119:
if(c > 0)
--c;
break;
case 115:
if(c < aLen)
++c;
break;
case 10:
o = 1;
break;
case 27:
o = 2;
break;
}
wrefresh(menu);
}
delwin(menu);
if(o == 1)
return c;
else
return -1;
}
int main()
{
if(fork())
hostGame();
}
|