# include <iostream.h>
# include <constrea.h>
# include <stdio.h>
# include <string.h>
# include <dos.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 vPantalla[4][80]={ {"                                             t    t                           "},
         {
"    PPPPPPPP          PPPPPPPPPPP         PPPPPPPPPPPPP                       "},
         {
"                   t                                                          "},
         {
"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP      PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"}
};




main()
{

clrscr();
_setcursortype(_NOCURSOR);

for (int columna=0;columna<70;columna++)
{
 
for (int fila=0;fila<4;fila++)
 {
  
gotoxy(columna+5,fila+10);
  
cout << vPantalla[fila][columna];
 }
}

int jugadorX=3; int jugadorY=2;

gotoxy(jugadorX+5,jugadorY+10);
printf("X");

char tecla=0;
int bSaltando=NO;
int bSeMurio=NO;
int distancia=0;
int direccion=1;
int puntos=0;
while (tecla !=27 && bSeMurio !=SI)
{
delay(20);
if (kbhit())
{
 
tecla=getch();
 
switch(tecla)
 {
 
case TECLA_DERECHA:
  
direccion=1;
  
gotoxy(jugadorX+5,jugadorY+10);
  
printf(" ");
  
jugadorX++;
  
gotoxy(jugadorX+5,jugadorY+10);
  
printf("X");
  
break;
 
case TECLA_IZQUIERDA:
  
direccion=-1;
  
gotoxy(jugadorX+5,jugadorY+10);
  
printf(" ");
  
jugadorX--;
  
gotoxy(jugadorX+5,jugadorY+10);
  
printf("X");
  
break;
 
case TECLA_ARRIBA:
  
bSaltando=SI;
  
break;
 }
// fin switch
} // fin kbhit()

if (bSaltando==SI && vPantalla[jugadorY-1][jugadorX]!='P')
{
  
gotoxy(jugadorX+5,jugadorY+10);
  
printf(" ");
  
jugadorY--;
  
jugadorX+=direccion;
  
gotoxy(jugadorX+5,jugadorY+10);
  
printf("X");
 
if (distancia<3)
   {
   
distancia++;
   }
 
else
  
{
   
bSaltando=NO;
   
distancia=0;
   }
}

if (vPantalla[jugadorY+1][jugadorX] != 'P' && bSaltando!=SI)
{
 
if (jugadorY<10)
 {
 
gotoxy(jugadorX+5,jugadorY+10);
 
printf(" ");
 
jugadorY++;
 
gotoxy(jugadorX+5,jugadorY+10);
 
printf("X");
 }
 
else
 
{
 
bSeMurio=SI;
 }
}

if (vPantalla[jugadorY][jugadorX+direccion] == 't')
{
 
puntos+=15;
 
vPantalla[jugadorY][jugadorX+direccion] = ' ';
 
gotoxy(jugadorX+5+direccion,jugadorY+10);
 
printf(" ");
 
sound(500);
 
delay(100);
 
nosound();
}




gotoxy (35, 2);
printf("Puntos: %d",puntos);

}
// 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;
}