-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacman.c
More file actions
94 lines (84 loc) · 3.13 KB
/
Copy pathpacman.c
File metadata and controls
94 lines (84 loc) · 3.13 KB
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
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
int x=12, y=12;
int grid[22][23] = {
{201,205,205,205,205,205,205,205,205,205,205,203,205,205,205,205,205,205,205,205,205,205,187},
{186,000,000,000,000,000,000,000,000,000,000,186,000,000,000,000,000,000,000,000,000,000,186},
{186,000,201,205,187,000,201,205,205,187,000,186,000,201,205,205,187,000,201,205,187,000,186},
{186,000,200,205,188,000,200,205,205,188,000,186,000,200,205,205,188,000,200,205,188,000,186},
{186,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,186},
{186,000,205,205,205,000,186,000,205,205,205,203,205,205,205,000,186,000,205,205,205,000,186},
{186,000,000,000,000,000,186,000,000,000,000,186,000,000,000,000,186,000,000,000,000,000,186},
{200,205,205,205,187,000,204,205,205,205,000,186,000,205,205,205,185,000,201,205,205,205,188},
{000,000,000,000,186,000,186,000,000,000,000,000,000,000,000,000,186,000,186,000,000,000,000},
{205,205,205,205,188,000,186,000,201,205,205,205,205,205,187,000,186,000,200,205,205,205,205},
{000,000,000,000,000,000,000,000,186,000,000,000,000,000,186,000,000,000,000,000,000,000,000},
{205,205,205,205,187,000,186,000,200,205,205,205,205,205,188,000,186,000,201,205,205,205,205},
{000,000,000,000,186,000,186,000,000,000,000,000,000,000,000,000,186,000,186,000,000,000,000},
{201,205,205,205,188,000,186,000,205,205,205,203,205,205,205,000,186,000,200,205,205,205,187},
{186,000,000,000,000,000,000,000,000,000,000,186,000,000,000,000,000,000,000,000,000,000,186},
{186,000,205,205,187,000,205,205,205,205,000,186,000,205,205,205,205,000,201,205,205,000,186},
{186,000,000,000,186,000,000,000,000,000,000,000,000,000,000,000,000,000,186,000,000,000,186},
{204,205,205,000,186,000,186,000,205,205,205,203,205,205,205,000,186,000,186,000,205,205,185},
{186,000,000,000,000,000,186,000,000,000,000,186,000,000,000,000,186,000,000,000,000,000,186},
{186,000,205,205,205,205,202,205,205,205,000,186,000,205,205,205,202,205,205,205,205,000,186},
{186,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,186},
{200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188}
};
void dumpChr(int chr)
{
printf("%c", chr);
}
void drawPlayer(int x, int y)
{
int i,k;
for(i=0;i<22;i++)
{
for(k=0;k<23;k++)
{
if(y == i && x == k) {
dumpChr(2);
} else {
dumpChr(grid[i][k]);
}
}
printf("\n");
}
}
void movePlayer(int x2, int y2)
{
x += x2;
y += y2;
system("cls");
drawPlayer(x,y);
}
main()
{
int key;
while(1)
{
system("cls");
drawPlayer(x,y);
key = getch();
switch(key)
{
case 113:
case 81: //quit on "q"
exit(0);
break;
case 119:
movePlayer(0,-1);
break;
case 115:
movePlayer(0,1);
break;
case 97:
movePlayer(-1,0);
break;
case 100:
movePlayer(1,0);
break;
}
}
}