I made some improvements to "exploring the path of the Maze. The villain does not go back when walking,
That is, the same point is not repeated.
/* Crazymaze. c */
/* 2003-8-26 */
# Include <stdlib. h>
# Include <time. h>
# Include <math. h>
# Include <stdio. h>
# Include <graphics. h>
# Define N 22
# Define M 22
# Define MAXLEN 200;
Int bg [M] [N];
Struct square {
Int x;
Int y;
Int direc;
} P [200];
Void makebg (int, int );
Void drawbg (int [] [], int );
Void drawman (int, int, int );
Void rect (int, int );
Void main () {/* main () start */
Int step = 20;
Int len = 10;
Int size = 20;
Int x = 0, y = 0, x0 = 0, y0 = 0;
Int I = 0, j = 0, k = 0, count = 0;
Int gdriver = DETECT, gmode;
Char ch;
Int direc;
Makebg (M, N );
/* Registerbgidriver (EGAVGA_driver );
Initgraph (& gdriver, & gmode, "c: \ turboc2 ");*/
Initgraph (& gdriver, & gmode, "c: \ tc20 \ bgi ");
Cleardevice ();
Setwritemode (XOR_PUT );
Settextstyle (1, 0, 3 );
Setcolor (GREEN );
Outtextxy (100,180, "Press <Q> to quit ");
Setcolor (BLUE );
Setfillstyle (LINE_FILL, BLUE );
Drawbg (bg, M, N, size, 0, 0 );
Setcolor (GREEN );
Outtextxy (60,120, "press key <1>: YOU ,");
Outtextxy (70,150, "other key: AUTOMATIC ");
Setcolor (WHITE );
X + = len; y + = len;
Drawman (x, y, len );
X0 = x; y0 = y;
If (ch = getch () = '1 '){
/* Manual control */
While (ch = getch ())! = 'Q '){
Delay (800 );
Drawman (x, y, len );
Switch (ch ){
Case 'A ':
If (j> 0 & bg [I] [J-1] = 0 ){
If (x> step) {x-= step; j --;};
}
Break;
Case's ':
If (I <M-1 & bg [I + 1] [j] = 0 ){
If (y <479-step) {y + = step; I ++ ;};
}
Break;