Rev16 de Junio del 2004
Tal vez esto te sirva, es algo simple sin tiempo ni nada pero hace lo del laberinto, y el usuario busca la salida:
#include <stdio.h>
#include <conio.h>
void PintarPantalla(int matriz[][70]);
const char paredes[]={'²','.','þ',' '};
#define ESC 27
void main(void)
{
int laberinto[20][70]=
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,0},
{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,1,0,1,0,0,1,1,0,1,0,1,0,1,0,1,1,1,1,0,0,0,1,0,1,1,0,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,0,1,0,1,1,0,1,1,0,1,1,1,0},
{0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,1,0,1,1,1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,0},
{0,0,1,1,1,0,1,1,0,1,0,0,1,1,1,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,1,0,1,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0},
{0,1,0,1,0,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,0,0,1,0,0,0,1,1,0,1,1,1,1,0,1,0,0,0,1,1,1,0,0,0,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0},
{0,1,1,1,1,1,1,0,0,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mov=getch();
if(mov==49 || mov==50 || mov==51 || mov==53)
{
short int temp=0,sigue=0;
switch(mov)
{
case 49:
temp=y-1;
if(laberinto[x][temp]!=0 && x>=1)
sigue=1;
break;
case 50:
temp=x+1;
if(laberinto[temp][y]!=0)
sigue=1;
break;
case 51:
temp=y+1;
if(laberinto[x][temp]!=0 && x>=1)
sigue=1;
break;
case 53:
temp=x-1;
if(laberinto[temp][y]!=0)
sigue=1;
break;
}//switch(mov)
if(sigue)
{
gotoxy(y+1,x+5); textcolor(15); cprintf("%c",paredes[1]);
switch(mov)
{
case 49:
y--; break;
case 50:
x++; break;
case 51:
y++; break;
case 53:
x--; break;
}//switch(mov)
}//if(sigue)
}//if(mov==49 || mov==50 || mov==51 || mov==53)
gotoxy(y+1,x+5); textcolor(4); cprintf("%c",paredes[2]);
if(laberinto[x][y]==3)
{
mov=ESC;
win=1;
}
}while(mov!=ESC);
if(win)
{ gotoxy(42,30); printf(" Ganaste !"); }
else
{ gotoxy(42,30); printf(" Perdiste !"); }
getch();
}
void PintarPantalla(int matriz[][70])
{
textcolor(15);
clrscr();
printf("nnttt Laberintonn");
for(short int a=0;a<=19;a++)
{
for(short int b=0;b<=69;b++)
{
if(matriz[a][b]!=2)
{ textcolor(15); cprintf("%c",paredes[matriz[a][b]]); }
else
{ textcolor(4); cprintf("%c",paredes[matriz[a][b]]); }
}
printf("n");
}
printf("nn Puedes moverte a travs del laberinto con las teclas:");
printf("nnt -----------------------");
printf("nt | Bloque Numerico |");
printf("nt -----------------------");
printf("nnt 5");
printf("nnt Arriba");
printf("nnt 1 2 3");
printf("nnt Derecha Abajo Izquierda");
}