-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNFS.c
91 lines (83 loc) · 1.61 KB
/
NFS.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define width 51
#define length 30
void ausgabe(char arr[length][width])
{
for (int i = 0; i < length; i++)
{
for (int j = 0; j < width; j++)
{
printf("%c", arr[i][j]);
}
}
}
void create(char arr[length][width])
{
for (int i = 0; i < length; i++)
{
for (int j = 0; j < width; j++)
{
arr[i][j] = '-';
if (j + 1 == width)
arr[i][j] = '\n';
}
}
}
int main()
{
char chr;
char arr[length][width];
char cursor = 'A';
int x = length / 2;
int y = width / 2;
for (int i = 0; i < 400; i++)
{
printf("use w,a,s,d to drive and l to leave the game.\n\n");
create(&arr);
arr[x][y] = cursor;
ausgabe(&arr);
scanf("%c", &chr);
system("cls");
arr[x][y] = '-';
switch (chr)
{
case 'w':
{
if (x > 0)
x--;
break;
}
case 's':
{
if (x < length - 1)
x++;
break;
}
case 'a':
{
if (y > 0)
y--;
break;
}
case 'd':
{
if (y < width - 2)
y++;
break;
}
case 'l':
{
return 1;
break;
}
default:
{
break;
}
}
}
return 0;
}