# include <iostream.h>
# include <constrea.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <dos.h>
# include <time.h>
# define IZQUIERDA -1
# define DERECHA 1
# define QUIETO 0
# define SI 1
# define NO 0
# define ANCHO_PANTALLA 80
# define ALTO_PANTALLA 24
# define TECLA_ARRIBA 72
# define TECLA_DERECHA 77
# define TECLA_IZQUIERDA 75
# define TECLA_ESPACIO 32
# define TECLA_ESCAPE 27
char pista[10][10];
main()
{
randomize();
for (int i=0;i<10;i++)
for (int j=0;j<10;j++)
pista[i][j]=' ';
clrscr();
_setcursortype(_NOCURSOR);
int jugadorX=45; int jugadorY=10;
gotoxy(jugadorX,jugadorY);
/*printf("oAo");
printf("] [");
printf("o-o");*/
char tecla=0;
int bSaltando=NO;
int bSeMurio=NO;
int distancia=0;
int direccion=1;
int puntos=0;
int pistaX=20; int pistaY=10;
while (tecla !=27 && bSeMurio !=SI)
{
delay(200);
if (kbhit())
{
tecla=getch();
switch(tecla)
{
case TECLA_DERECHA:
direccion=1;
gotoxy(jugadorX,jugadorY);
printf(" ");
jugadorX++;
gotoxy(jugadorX,jugadorY);
printf("A");
break;
case TECLA_IZQUIERDA:
direccion=-1;
gotoxy(jugadorX,jugadorY);
printf(" ");
jugadorX--;
gotoxy(jugadorX,jugadorY);
printf("A");
break;
} // fin switch
} // fin kbhit()
distancia= rand() % 3;
for (int y=9;y>0;y--)
{
for (int x=0;x<10;x++)
{
pista[y][x]=pista[y-1][x];
}
}
for (int x=0;x<10;x++)
{
pista[0][x]=' ';
}
pista[0][distancia]='|';
pista[0][distancia+7]='|';
for (y=0;y<10;y++)
{
for (x=0;x<10;x++)
{
gotoxy(x+40,y+5);
printf("%c",pista[y][x]);
}
}
gotoxy(jugadorX,jugadorY);
printf("A");
if (pista[5][jugadorX-40]=='|')
{
sound(450);
delay(50);
nosound();
}
} // fin while tecla
if (bSeMurio==SI)
{
sound(100);
delay(100);
sound(10);
delay(100);
sound(50);
delay(400);
nosound();
clrscr();
printf(" --= LO SIENTO =--");
}
getch();
return 0;
}