#include #include #include "p1304a.h" void move(PLAYER *p, int dx, int dy) { printf("その方向には逃げることができません\n"); } int main(void) { int i, n, dx, dy; PLAYER you, hunter; printf("あなたの名前を入力してください:"); scanf("%s", you.name); you.x = you.y = 0; strcpy(hunter.name, "hunter"); hunter.x = WIDTH-1; hunter.y = HEIGHT-1; print_map(you, hunter); for ( i = 1; i <= MAX; i++ ) { while(1) { printf("[%d 回目]", i); printf("\nどの方向に逃げますか?(1:上,2:右,3:下,4:左)\n> "); scanf("%d", &n); dx = dy = 0; if ( n == 1 ){ dy = 1; } else if ( n == 2 ){ dx = 1; } else if ( n == 3 ){ dy = -1; } else if ( n == 4 ){ dx = -1;; } if ( n >= 1 && n <= 4 ) { break; } } move(&you, dx, dy); approach(&you, &hunter); print_map(you, hunter); if ( you.x == hunter.x && you.y == hunter.y ) { printf("%s は捕まってしまいました... GAME OVER\n", you.name); return 0; } } printf("%s は無事に逃げ切りました. CLEAR!\n", you.name); return 0; }