#include <iostream>
#include <stdlib.h>
#include <string>
#include <conio.h>
#include <windows.h>
#include <stdio.h>
#include <time.h>
using namespace std;
void gotoxy_(int x,int y);
void cuadrado();
void objeto();
void error();
void hora();
void crono();
void menu();
void moverobjeto();
int x,y,x1,y1,x2,y2;
int key=0;
int main()
{
srand(time(NULL));
hora();
menu();
//crono();
cuadrado();
x2=19;
y2=12;
gotoxy_(x2,y2);
cout<<'a';
x= 19; y= 16; gotoxy_(x,y);
while(key!=27)
{
key=getch();
if(key==72|key==75|key==80|key==77)
{
x1=x;
y1=y;
}
if(x==x2 && y==y2+1)
{
gotoxy_(x2,y2);
cout<<' ';
y2++;
gotoxy_(x2,y2);
cout<<'a';
}
if(x==x2+1 && y==y2)
{
gotoxy_(x2,y2);
cout<<' ';
x2++;
gotoxy_(x2,y2);
cout<<'a';
}
if(key==80)
{
if(x==x2 && y==y2-1)
{
gotoxy_(x2,y2);
cout<<' ';
y2--;
gotoxy_(x2,y2);
cout<<'a';
}
}
if(key==77)
{
if(x==x2 && y==y2)
{
gotoxy_(x2,y2);
cout<<' ';
x2++;
gotoxy_(x2,y2);
cout<<'a';
}
}
if(key==72)
{
//cout<<"up"<<endl;
y--;
if (y<11)
{
error();
}
}
if(key==75)
{
//cout<<"left"<<endl;
x--;
if (x<11)
{
error();
}
}
if(key==80)
{
//cout<<"down"<<endl;
y++;
if (y>19)
{
error();
}
}
if(key==77)
{
//cout<<"right"<<endl;
x++;
if (x>33)
{
error();
}
}
if(key==72|key==75|key==80|key==77)
{
gotoxy_(x,y);
cout<<' ';
gotoxy_(x,y);
cout<<'O';
gotoxy_(x1,y1);
cout<<' ';
}
if(x>=14 && x<=33 && y==17)
{
error();
}
if(x>=10 && x<=27 && y==13)
{
error();
}
}//end while
getch();
}
void cuadrado()
{
x= 10; y= 20; gotoxy_(x,y);
printf("*");
x= 11; y= 20; gotoxy_(x,y);
printf("*");
x= 12; y= 20; gotoxy_(x,y);
printf("*");
x= 13; y= 20; gotoxy_(x,y);
printf("*");
x= 14; y= 20; gotoxy_(x,y);
printf("*");
x= 15; y= 20; gotoxy_(x,y);
printf("*");
x= 16; y= 20; gotoxy_(x,y);
printf("*");
x= 17; y= 20; gotoxy_(x,y);
printf("*");
x= 18; y= 20; gotoxy_(x,y);
printf("*");
x= 19; y= 20; gotoxy_(x,y);
printf("*");
x= 20; y= 20; gotoxy_(x,y);
printf("*");
x= 21; y= 20; gotoxy_(x,y);
printf("*");
x= 22; y= 20; gotoxy_(x,y);
printf("*");
x= 23; y= 20; gotoxy_(x,y);
printf("*");
x= 24; y= 20; gotoxy_(x,y);
printf("*");
x= 25; y= 20; gotoxy_(x,y);
printf("*");
x= 26; y= 20; gotoxy_(x,y);
printf("*");
x= 27; y= 20; gotoxy_(x,y);
printf("*");
x= 28; y= 20; gotoxy_(x,y);
printf("*");
x= 29; y= 20; gotoxy_(x,y);
printf("*");
x= 30; y= 20; gotoxy_(x,y);
printf("*");
x= 31; y= 20; gotoxy_(x,y);
printf("*");
x= 32; y= 20; gotoxy_(x,y);
printf("*");
x= 33; y= 20; gotoxy_(x,y);
printf("*");
x= 34; y= 20; gotoxy_(x,y);
printf("*");
////////////////
x= 10; y= 10; gotoxy_(x,y);
printf("*");
x= 11; y= 10; gotoxy_(x,y);
printf("*");
x= 12; y= 10; gotoxy_(x,y);
printf("*");
x= 13; y= 10; gotoxy_(x,y);
printf("*");
x= 14; y= 10; gotoxy_(x,y);
printf("*");
x= 15; y= 10; gotoxy_(x,y);
printf("*");
x= 16; y= 10; gotoxy_(x,y);
printf("*");
x= 17; y= 10; gotoxy_(x,y);
printf("*");
x= 18; y= 10; gotoxy_(x,y);
printf("*");
x= 19; y= 10; gotoxy_(x,y);
printf("*");
x= 20; y= 10; gotoxy_(x,y);
printf("*");
x= 21; y= 10; gotoxy_(x,y);
printf("*");
x= 22; y= 10; gotoxy_(x,y);
printf("*");
x= 23; y= 10; gotoxy_(x,y);
printf("*");
x= 24; y= 10; gotoxy_(x,y);
printf("*");
x= 25; y= 10; gotoxy_(x,y);
printf("*");
x= 26; y= 10; gotoxy_(x,y);
printf("*");
x= 27; y= 10; gotoxy_(x,y);
printf("*");
x= 28; y= 10; gotoxy_(x,y);
printf("*");
x= 29; y= 10; gotoxy_(x,y);
printf("*");
x= 30; y= 10; gotoxy_(x,y);
printf("*");
x= 31; y= 10; gotoxy_(x,y);
printf("*");
x= 32; y= 10; gotoxy_(x,y);
printf("*");
x= 33; y= 10; gotoxy_(x,y);
printf("*");
x= 34; y= 10; gotoxy_(x,y);
printf("*");
//////////
x= 34; y= 11; gotoxy_(x,y);
printf("*");
x= 34; y= 12; gotoxy_(x,y);
printf("*");
x= 34; y= 13; gotoxy_(x,y);
printf("*");
x= 34; y= 14; gotoxy_(x,y);
printf("*");
x= 34; y= 15; gotoxy_(x,y);
printf("*");
x= 34; y= 16; gotoxy_(x,y);
printf("*");
x= 34; y= 17; gotoxy_(x,y);
printf("*");
x= 34; y= 18; gotoxy_(x,y);
printf("*");
x= 34; y= 19; gotoxy_(x,y);
printf("*");
x= 10; y= 11; gotoxy_(x,y);
printf("*");
x= 10; y= 12; gotoxy_(x,y);
printf("*");
x= 10; y= 13; gotoxy_(x,y);
printf("*");
x= 10; y= 14; gotoxy_(x,y);
printf("*");
x= 10; y= 15; gotoxy_(x,y);
printf("*");
x= 10; y= 16; gotoxy_(x,y);
printf("*");
x= 10; y= 17; gotoxy_(x,y);
printf("*");
x= 10; y= 18; gotoxy_(x,y);
printf("*");
x= 10; y= 19; gotoxy_(x,y);
printf("*");
//dentro
x= 10; y= 13; gotoxy_(x,y);
printf("*");
x= 11; y= 13; gotoxy_(x,y);
printf("*");
x= 12; y= 13; gotoxy_(x,y);
printf("*");
x= 13; y= 13; gotoxy_(x,y);
printf("*");
x= 14; y= 13; gotoxy_(x,y);
printf("*");
x= 15; y= 13; gotoxy_(x,y);
printf("*");
x= 16; y= 13; gotoxy_(x,y);
printf("*");
x= 17; y= 13; gotoxy_(x,y);
printf("*");
x= 18; y= 13; gotoxy_(x,y);
printf("*");
x= 19; y= 13; gotoxy_(x,y);
printf("*");
x= 20; y= 13; gotoxy_(x,y);
printf("*");
x= 21; y= 13; gotoxy_(x,y);
printf("*");
x= 22; y= 13; gotoxy_(x,y);
printf("*");
x= 23; y= 13; gotoxy_(x,y);
printf("*");
x= 24; y= 13; gotoxy_(x,y);
printf("*");
x= 25; y= 13; gotoxy_(x,y);
printf("*");
x= 26; y= 13; gotoxy_(x,y);
printf("*");
x= 27; y= 13; gotoxy_(x,y);
printf("*");
//
x= 14; y= 17; gotoxy_(x,y);
printf("*");
x= 15; y= 17; gotoxy_(x,y);
printf("*");
x= 16; y= 17; gotoxy_(x,y);
printf("*");
x= 17; y= 17; gotoxy_(x,y);
printf("*");
x= 18; y= 17; gotoxy_(x,y);
printf("*");
x= 19; y= 17; gotoxy_(x,y);
printf("*");
x= 20; y= 17; gotoxy_(x,y);
printf("*");
x= 21; y= 17; gotoxy_(x,y);
printf("*");
x= 22; y= 17; gotoxy_(x,y);
printf("*");
x= 23; y= 17; gotoxy_(x,y);
printf("*");
x= 24; y= 17; gotoxy_(x,y);
printf("*");
x= 25; y= 17; gotoxy_(x,y);
printf("*");
x= 26; y= 17; gotoxy_(x,y);
printf("*");
x= 27; y= 17; gotoxy_(x,y);
printf("*");
x= 28; y= 17; gotoxy_(x,y);
printf("*");
x= 29; y= 17; gotoxy_(x,y);
printf("*");
x= 30; y= 17; gotoxy_(x,y);
printf("*");
x= 31; y= 17; gotoxy_(x,y);
printf("*");
x= 32; y= 17; gotoxy_(x,y);
printf("*");
x= 33; y= 17; gotoxy_(x,y);
printf("*");
}
void gotoxy_(int x,int y)
{
HANDLE consola;
COORD posicion;
consola = GetStdHandle(STD_OUTPUT_HANDLE);
posicion.X= x;
posicion.Y= y;
SetConsoleCursorPosition(consola, posicion);
}
void error()
{
system("cls");
printf("GAME OVER!!");
printf("n");
printf("Pulse escape para empezar de nuevo");
if (key==27)
{
system("cls");
//ir a main
}
}
void hora()
{
time_t rawtime;
time ( &rawtime );
printf ( "La hora actual es: %s", ctime (&rawtime) );
}
void crono()
{
int segundos, minutos, horas;
segundos = minutos = horas = 0;
while (minutos < 2){
if (segundos == 60){
minutos++;
segundos = 0;
}
if (minutos == 60){
horas++;
minutos = 0;
}
printf("%02d:%02d:%02dn", horas, minutos, segundos);
Sleep(1000);
segundos++;
}
}
void menu()
{
system("color 1f");
printf("nssssssss oooooooo kk kkk oooooooo bbbbbbbb aaaaaaaaaa nnn nnnnn");
printf("nssssssss oooooooo kkk kkk oooooooo bbbb b aaa aaaa nnnn nnnnn");
printf("nssss oooooooo kkk kkkk oooooooo bbbbb b aaa aaaa nnnnnnnnnn");
printf("nsss ooo ooo kkkkkkk ooo ooo bbbbb b aaaaaaaaaa nnnnnnnnnn");
printf("nssssssss ooo ooo kkkkkk ooo ooo bbbbbbbb aaaaaaaaaa nnnnnnnnnn");
printf("nssssssss ooo ooo kkkkkkk ooo ooo bbbbb b aaaaaaaaaa nnnnnnnnnn");
printf("n ssss oooooooo kkk kkk oooooooo bbbbb b aaaaaaaaaa nnnnnnnnnn");
printf("nssssssss oooooooo kkk kkkk oooooooo bbbbb b aaa aaaa n nnnnnnn");
printf("nssssssss oooooooo kkk kkkk oooooooo bbbbbbbb aaa aaaa n nnnnnn");