| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1404 人关注过本帖
标题:[求助]解释一下pacman程序代码!
只看楼主 加入收藏
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
 问题点数:0 回复次数:12 
[求助]解释一下pacman程序代码!
代码

[此贴子已经被作者于2006-11-6 14:25:35编辑过]


搜索更多相关主题的帖子: pacman 代码 解释 
2006-11-06 12:21
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
没传上来
2006-11-06 12:37
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
得分:0 
是阿,不知如何作阿?明明说成功上传,我已经传2次了。

2006-11-06 13:05
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
得分:0 
代码如下:

#include <stdio.h>
9: #include <stdlib.h>
10: #include <conio.h>
11: #include <dos.h>
12: #include <graphics.h>
13:
14: #define K_UP 72
15: #define K_DOWN 80
16: #define K_RIGHT 77
17: #define K_LEFT 75
18:
19: enum Direction { UP=1,DOWN=2,LEFT=3,RIGHT=4};
20:
21: int score=0;
22: int game_over=0;
23:
24: char maze[19][27]={{1,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1},
25: {1,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,1},
26: {1,2,1,3,1,3,1,3,1,3,3,3,3,3,3,3,3,3,1,3,1,3,1,3,1,2,1},
27: {1,3,1,3,1,3,1,3,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,3,1,3,1},
28: {1,3,3,3,1,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,1,3,3,3,1},
29: {1,3,1,1,1,3,1,1,3,1,1,1,1,1,1,1,1,1,3,1,1,3,1,1,1,3,1},
30: {1,3,1,1,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,1,1,3,1},
31: {1,3,1,1,3,1,3,1,1,3,1,1,0,0,0,1,1,3,1,1,3,1,3,1,1,3,1},
32: {1,3,1,3,3,1,3,1,1,3,1,0,0,0,0,0,1,3,1,1,3,1,3,3,1,3,1},
33: {1,3,1,3,3,3,3,3,3,3,1,0,0,0,0,0,1,3,3,3,3,3,3,3,1,3,1},
34: {1,3,1,1,1,1,3,1,1,3,1,1,1,1,1,1,1,3,1,1,3,1,1,1,1,3,1},
35: {1,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,1},
36: {1,1,1,1,1,3,1,1,3,1,1,1,1,1,1,1,1,1,3,1,1,3,1,1,1,1,1},
37: {1,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,1},
38: {1,3,1,3,1,3,1,3,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,3,1,3,1},
39: {1,2,1,3,1,3,1,3,1,3,3,3,3,3,3,3,3,3,1,3,1,3,1,3,1,2,1},

40: {1,3,1,3,1,3,3,3,3,3,1,1,1,3,1,1,1,3,3,3,3,3,1,3,1,3,1},
41: {1,3,3,3,1,1,1,3,1,1,1,3,3,3,3,3,1,1,1,3,1,1,1,3,3,3,1},
42: {1,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1}};
43:
44: void main()
45: {
46:
47: int gd=VGA,gm=VGAHI;
48:
49: int pac_x,pac_y;
50: enum Direction act,last_act;
51:
52: int ghost_x[3],ghost_y[3];
53: int ghost_color[3];
54: int ghost_dir[3];
55: int old_ghost_x;
56: int old_ghost_y;
57: int g_no=0;
58:
59: int status;
60: int old_status;
61:
62: int j,k,key;
63: int dice;
64:
65: void maze_draw(void);
66: void draw(int pac_x,int pac_y,int action,int color,int body);
67: void dot(int pac_x,int pac_y,int action,int color,int j,int i);
68: void scoretext(int score_app);
69: void tone(int tone_no);
70:
71:
72: initgraph(&gd,&gm,"");
73:
74: setcolor(3);
75: rectangle(10,60,621,479);
76: rectangle(15,65,616,474);
77: setcolor(10);
78: settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
79: outtextxy(10,30,"Score :");
80:
81: maze_draw();
82:
83: setcolor(14);
84: rectangle(161,60,183,65);
85: rectangle(161,474,183,479);
86: rectangle(449,60,473,65);
87: rectangle(449,474,473,479);
88:
89: pac_x=13;
90: pac_y=13;
91: maze[pac_y][pac_x]=5;
92:
93: act=RIGHT;
94: last_act=RIGHT;
95: draw(pac_x,pac_y,act,14,1);
96:
97: ghost_x[0]=12; ghost_y[0]=9; ghost_color[0]=13; ghost_dir[0]=LEFT;
98: ghost_x[1]=13; ghost_y[1]=9; ghost_color[1]=15; ghost_dir[1]=DOWN;
99: ghost_x[2]=14; ghost_y[2]=9; ghost_color[2]=9; ghost_dir[2]=RIGHT;
100:
101: maze[ghost_y[0]][ghost_x[0]]=10;
102: maze[ghost_y[1]][ghost_x[1]]=10;
103: maze[ghost_y[2]][ghost_x[2]]=10;
104:
105: draw(ghost_x[0],ghost_y[0],4,ghost_color[0],2);
106: draw(ghost_x[1],ghost_y[1],4,ghost_color[1],2);
107: draw(ghost_x[2],ghost_y[2],4,ghost_color[2],2);
108:
109: score=0;
110: tone(3);
111: scoretext(10);
112:
113: randomize();
114:
115: while(game_over!=1)
116: {
117: if(kbhit())
118: {
119: if((key=getch())==27)
120: {
121: break;

122: }
123: else
124: {
125:
126: key=getch();
127:
128: if(key==K_UP)
129: {
130: maze[pac_y][pac_x]=0;
131: draw(pac_x,pac_y,act,0,1);
132:
133: act=UP;
134:
135: if(act==last_act)
136: {
137: pac_y=pac_y-1;
138: status=maze[pac_y][pac_x];
139:
140: switch(status)
141: {
142: case 0:
143: maze[pac_y][pac_x]=5;
144: break;
145: case 1:
146: pac_y=pac_y+1;
147: maze[pac_y][pac_x]=5;
148: draw(pac_x,pac_y,act,14,1);
149: tone(status);
150: continue;
151: case 2:
152: scoretext(90);
153: case 3:
154: scoretext(10);
155: maze[pac_y][pac_x]=5;
156: break;
157: case 4:
158: pac_y=17;
159: tone(status);
160: draw(pac_x,pac_y,1,14,1);
161: continue;
162: default:
163: game_over=1;

164: tone(5);
165: continue;
166: }
167: }
168: else
169: {
170: maze[pac_y][pac_x]=5;
171: last_act=UP;
172: }
173: draw(pac_x,pac_y,UP,14,1);
174: tone(status);
175: }
176:
177: if(key==K_DOWN)
178: {
179: maze[pac_y][pac_x]=0;
180: draw(pac_x,pac_y,act,0,1);
181:
182: act=DOWN;
183:
184: if(act==last_act)
185: {
186: pac_y=pac_y+1;
187: status=maze[pac_y][pac_x];
188:
189: switch(status)
190: {
191: case 0:
192: maze[pac_y][pac_x]=5;
193: break;
194: case 1:
195: pac_y=pac_y-1;
196: maze[pac_y][pac_x]=5;
197: draw(pac_x,pac_y,act,14,1);
198: tone(status);
199: continue;
200: case 2:
201: scoretext(90);
202: case 3:
203: scoretext(10);
204: maze[pac_y][pac_x]=5;
205: break;
206: case 4:
207: pac_y=1;
208: tone(status);
209: draw(pac_x,pac_y,2,14,1);
210: continue;
211: default:
212: game_over=1;
213: tone(5);
214: continue;
215: }
216: }
217: else
218: {
219: maze[pac_y][pac_x]=5;
220: last_act=DOWN;
221: }
222: draw(pac_x,pac_y,DOWN,14,1);
223: tone(status);
224: }
225:
226: if(key==K_LEFT)
227: {
228: maze[pac_y][pac_x]=0;
229: draw(pac_x,pac_y,act,0,1);
230:
231: act=LEFT;
232:
233: if(act==last_act)
234: {
235: pac_x=pac_x-1;
236: status=maze[pac_y][pac_x];
237:
238: switch(status)
239: {
240: case 0:
241: maze[pac_y][pac_x]=5;
242: break;
243: case 1:
244: pac_x=pac_x+1;
245: maze[pac_y][pac_x]=5;
246: draw(pac_x,pac_y,act,14,1);
247: tone(status);
248: continue;
249: case 2:
250: scoretext(90);
251: case 3:
252: scoretext(10);
253: maze[pac_y][pac_x]=5;
254: break;
255: default:
256: 257: tone(5);
258: continue;
259: }
260: }
261: else
262: {
263: maze[pac_y][pac_x]=5;
264: last_act=LEFT;
265: }
266: draw(pac_x,pac_y,LEFT,14,1);
267: tone(status);
268: }
269:
270: if(key==K_RIGHT)
271: {
272: maze[pac_y][pac_x]=0;
273: draw(pac_x,pac_y,act,0,1);
274:
275: act=RIGHT;
276:
277: if(act==last_act)
278: {
279:
280: pac_x=pac_x+1;
281: status=maze[pac_y][pac_x];
282:



2006-11-06 13:46
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
得分:0 

283: switch(status)
284: {
285: case 0:
286: maze[pac_y][pac_x]=5;
287: break;
288: case 1:
289: pac_290: maze[pac_y][pac_x]=5;
291: draw(pac_x,pac_y,act,14,1);
292: tone(status);
293: continue;
294: case 2:
295: scoretext(90);
296: case 3:
297: scoretext(10);
298: maze[pac_y][pac_x]=5;
299: break;
300: default:
301: game_over=1;
302: tone(5);
303: continue;
304: }
305: }
306: else
307: {
308: maze[pac_y][pac_x]=5;
309: last_act=RIGHT;
310: }
311: draw(pac_x,pac_y,RIGHT,14,1);
312: tone(status);
313: }
314: }
315: }
316:
317: dice=random(10);
318: if(dice==0)
319: {
320: g_no=random(3);
321: }
322:
323: dice=random(10);
324: if(dice<=1)
325: {
326: ghost_dir[g_no]=random(4)+1;
327: }
329: old_ghost_y=ghost_y[g_no];
330: old_ghost_x=ghost_x[g_no];
331: old_status=maze[ghost_y[g_no]][ghost_x[g_no]];
332:
333: switch(ghost_dir[g_no])
334: {
335: case UP: ghost_y[g_no]--;break;
336: case DOWN: ghost_y[g_no]++;break;
337: case LEFT: ghost_x[g_no]--;break;
338: case RIGHT:ghost_x[g_no]++;break;
339: }
340:
341: switch(maze[ghost_y[g_no]][ghost_x[g_no]])
342: {
343: case 1:
344: case 10:
345: case 12:
346: case 13:
347: ghost_dir[g_no]=random(4)+1;
348: ghost_y[g_no]=old_ghost_y;
349: ghost_x[g_no]=old_ghost_x;
350: break;
351: case 4:
352: if(ghost_dir[g_no]==DOWN)
353: {
354: ghost_y[g_no]=1;
355: }
356: else
357: {
358: ghost_y[g_no]=17;
359: }
360: case 0:
361: case 2:
362: case 3:
363: draw(old_ghost_x,old_ghost_y,4,0,2);
364:
365: if(old_status==10)
366: {
367: maze[old_ghost_y][old_ghost_x]=0;
368: }
369: if(old_status==12)
370: {
371: setcolor(12);
372: circle(24*old_ghost_x+5,24*old_ghost_y+55,7);
373: maze[old_ghost_y][old_ghost_x]=2;
374: }
375: if(old_status==13)
376: {
377: setcolor(7);
378: bar(24*old_ghost_x+3,24*old_ghost_y+53,24*old_ghost_x+7,24*old_ghost_y+57);
379: maze[old_ghost_y][old_ghost_x]=3;
380: }
381:
382: maze[ghost_y[g_no]][ghost_x[g_no]]+=10;
383: draw(ghost_x[g_no],ghost_y[g_no],4,ghost_color[g_no],2);
384: break;
385: case 5:
386: maze[old_ghost_y][old_ghost_x]=0;
387: draw(old_ghost_x,old_ghost_y,4,0,2);
388:
389: maze[ghost_y[g_no]][ghost_x[g_no]]=15;
390: draw(ghost_x[g_no],ghost_y[g_no],4,(-1)*ghost_color[g_no],2);
391: tone(5);
392: game_over=1;
393: break;
394: }
395:
396: }
397:
398: closegraph();
399: printf("score = %d",score);
400:
401:}
402:
403:void draw(int maze_x,int maze_y,int action,int color,int body)
404:{
405: int i,j,k;
406: int point,k1;
407:
408: void dot(int pac_x,int pac_y,int action,int color,int j,int i);
409:
410: char a[3][24][24]={
411: {{0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0},
412: {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
413: {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
414: {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
415: {0,0,0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0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
477: {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
478: {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
479: {0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0},
480: {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
481: {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
482: {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
483: {0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
484: {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
485: };

2006-11-06 13:48
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
得分:0 
486:
487: char b[24][24]={ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
488: {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
489: {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
490: {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
491: {0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0},
492: {0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0},
493: {0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0},
494: {0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,1,0,0,0,0},
495: {0,0,0,0,0,1,1,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,0,0},
496: {0,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,0,0},
497: {0,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,0},
498: {0,0,0,0,1,0,0,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,0},
499: {0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,0,0,0},
500: {0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
501: {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},
502: {0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0},
503: {0,0,1,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,1,0},
504: {0,0,1,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,1,0},
505: {0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0},
506: {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0},
507: {0,0,0,1,0,0,0,0,1,1,0,0,0,0,1,0,1,1,0,0,0,1,0,0},
508: {0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1,1,1,1,0,0,0},
509: {0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0},
510: {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
511: };
512:
513: for(k=1;k<=(body==2?1:5);k++)
514: {
515:
516: for(i=0;i<=23;i++)
517: {
518: for(j=0;j<=23;j++)
519: {
520:
521:
522: if((k==1)||(k==2)||(k==3))
523: {
524: k1=k-1;
525: }
526: else if(k==4528: k1=1;
529: }
530: else
531: {
532: k1=0;
533: }
534:
535: if(color==0)
536: {
537: k=5;
538: dot(maze_x,maze_y,action,0,j,i);
539: continue;
540: }
541:
542: if((action==1)||(action==2))
543: {
544: point=a[k1][j][i];
545: }
546:
547: if((action==3)||(action==4))
548: {
549: point=a[k1][i][j];
550: }
551:
552: if(body==2)
553: {
554: point=b[i][j];
555: }
556:
557: if(point==1)
558: {
559: dot(maze_x,maze_y,action,(color>=0)?color:(-1)*color,j,i);
560: }561: else
562: {
563: if(color>0)
564: {
565: dot(maze_x,maze_y,action,0,j,i);
566: }
567: }
568: }
569: }
570: }
571:}
572:
573:void dot(int maze_x,int maze_y,int action,int color,int j,int i)
574:{
575: int true_x;
576: int true_y;
577:
578: true_x=(maze_x-1)*24+16;
579: true_y=(maze_y-1)*24+66;
580:
581: switch(action)
582: {
583: case UP:
584: putpixel(true_x+j,true_y-i+23,color);
585: break;
586: case DOWN:
587: putpixel(true_x+j,true_y+i,color);
588: break;
589: case LEFT:
590: putpixel(true_x-j+23,true_y+i,color);
591: break;
592: case RIGHT:
593: putpixel(true_x+j,true_y+i,color);
594: break;
595: }
596:}
597:
598:void tone(int tone_no)
599:{
600: int i,j;


527: {


2006-11-06 13:50
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
前面还有数字
都不能粘贴也不能让我们一点一点照着打一遍吧
2006-11-06 13:51
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
得分:0 
602: switch(tone_no)
603: {
604: case 1:
605: sound(800);delay(10);
606: sound(900);delay(10);
607: nosound();
608: break;
609: case 2:
610: for(j=1;j<=5;j++)
611: {
612: for(i=3000;i>=400;i=i-300)
613: {
614: sound(i);
615: delay(50);
616: }
617: }
618: nosound();
619: break;
620: case 3:
621: sound(659);delay(25);
622: sound(523);delay(25);
623: nosound();
624: break;
625: case 4:
626: for(i=1000;i<=5000;i=i+200)
627: {
628: sound(i);
629: delay(25);
630: }
631: nosound();
632: break;
633: case 5:
634: for(i=500;i<=1000;i=i+10)
635: {
636: sound(i);
637: delay(50);
638: }
639: for(i=1000;i<=500;i=i-10)
640: {
641: sound(i);
642: delay(50);
643: }
644: nosound();
645: break;
646: }
647:}
648:
649:void scoretext(int score_app)
650:{
651: char ss[10];
652:
653: itoa(score,ss,10);
654:
655: setcolor(0);
656: outtextxy(90,30,ss);
657:
658: score=score+score_app;
659: itoa(score,ss,10);
660:
661: setcolor(11);
662: outtextxy(90,30,ss);
663:}
664:
665:void maze_draw(void)
666:{
667: int i,j;
668:
669: for(i=1;i<18;i++)
670: {
671: for(j=1;j<26;j++)
672: {
673: switch(maze[i][j])
674: {
675:
676: case 1:
677: setcolor(3);
678: rectangle(24*j-7,24*i+42,24*j+14,24*i+64);
679: rectangle(24*j-5,24*i+44,24*j+12,24*i+62);
680: break;
681:
682: case 2:
683: setcolor(12);
684: circle(24*j+5,24*i+55,7);
685: break;
686:
687: case 3:
688: setcolor(7);
689: bar(24*j+3,24*i+53,24*j+7,2^@4*i+57);^@^@
690: break;
691: }
692: }
693: }
694:}


2006-11-06 13:54
C语言学习者
Rank: 4
等 级:贵宾
威 望:13
帖 子:1278
专家分:0
注 册:2006-9-26
收藏
得分:0 

这个叫人怎样看呢


谁有强殖装甲第二部,可以Q我460054868
2006-11-06 16:16
huzi00008
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2006-10-9
收藏
得分:0 
上传说是成功,可就是看不见了。请指教

2006-11-06 16:28
快速回复:[求助]解释一下pacman程序代码!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048949 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved