-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvader.c
More file actions
42 lines (34 loc) · 781 Bytes
/
Copy pathinvader.c
File metadata and controls
42 lines (34 loc) · 781 Bytes
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
/* [ASCII Invader]
* File: invader.c
* Description: メインプログラム(エントリポイント)
* Author: Hayato OKUMOTO
* Copyright: (C)Hayato OKUMOTO, Yuta KOBAYASHI. 2013
*/
#include "invader.h"
int main(int argc, char **argv) {
int soc;
int is_server;
char hostname[HOSTNAME_LENGTH];
char yn;
printf("Are you host?(y or n): ");
scanf("%[yn]%*c", &yn);
if(yn == 'y') {
// server
if((soc = init_server(PORT)) == -1) {
exit(1);
}
is_server = TRUE;
} else {
// client
printf("input server's hostname: ");
fgets(hostname, HOSTNAME_LENGTH, stdin);
nl_to_null(hostname, HOSTNAME_LENGTH);
if((soc = init_client(hostname, PORT)) == -1) {
exit(1);
}
is_server = FALSE;
}
game_init(soc, is_server);
game_loop();
return 0;
}