#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <bios.h>
/*Programa: Cruz q tiene movimientos delimitados por las esquinas
*programador:Luis Altobeli 2 sept 2005
*UAZ Ing. en computacion Orgullosamente UAZ!!!!
*Derechos reservados
*vegan power xaltox
*/
union teclas
{
char c[2];
int i;
};
main()
{
void instrucciones(void);
void dibujar_rect(int *,int *,int *,int *,int *,int *,int *);
void mover_izq(int *,int *,int *,int *,int *,int *,int *);
void mover_der(int *,int *,int *,int *,int *,int *,int *);
void mover_arriba(int *,int *,int *,int *,int *,int *,int *);
void mover_abajo(int *,int *,int *,int *,int *,int *,int *);
int a=38;
int b=40;
int x=12;
int d=13;
int e=14;
int z=11;
int g=10;
union teclas f;
instrucciones();
clrscr();
clrscr();
dibujar_rect(&a,&b,&x,&d,&e,&z,&g);
do{
f.i=bioskey(0);
if(f.c[1])
{
switch(f.c[1])
{
case 72:
clrscr();
mover_arriba(&a,&b,&x,&d,&e,&z,&g);
if (g==1){
gotoxy(35,12);
printf("xLimite superiorx!!!!");
}
else {
e=e-1;
d=d-1;
x=x-1;
z=z-1;
g=g-1;}
break;
case 80:
clrscr();
mover_abajo(&a,&b,&x,&d,&e,&z,&g);
if (e==25){
gotoxy(35,12);
printf("xLimite Inferiorx!!!!");}
else{
e=e+1;
d=d+1;
x=x+1;
z=z+1;
g=g+1;
}
break;
case 75:
clrscr();
mover_izq(&a,&b,&x,&d,&e,&z,&g);
if(a==1){
gotoxy(35,12);
printf("xLimite izquierdox");}
else{
a=a-1;
b=b-1;
}
break;
case 77:
clrscr();
mover_der(&a,&b,&x,&d,&e,&z,&g);
if(a==75){
gotoxy(35,12);
printf("xLimite Derechox");}
else{
a=a+1;
b=b+1;
}
break;
default:
gotoxy(1,1);
printf("xdebes presionar solo lo que esta en el menux!!! ");
}
}
} while(f.c[0]!=27);
}
void dibujar_rect(int *a,int *b,int *x,int *d,int *e,int *z,int *g)
{
gotoxy(*a,*x);
printf(""); //CARITAS DEL CENTRO
gotoxy(*b,*d);
printf("");
gotoxy(*b,*e);
printf(""); //CARITAS DE ARRIBA
gotoxy(*b,*z);
printf("");
gotoxy(*b,*g);
printf(""); //CARITAS DE ABAJO
}
void mover_izq(int *a,int *b,int *x,int *d,int *e,int *z,int *g)
{
gotoxy(*a,*x);
printf(""); //CARITAS DEL CENTRO
gotoxy(*b,*d);
printf("");
gotoxy(*b,*e);
printf(""); //CARITAS DE ARRIBA
gotoxy(*b,*z);
printf("");
gotoxy(*b,*g);
printf(""); //CARITAS DE ABAJO
}
void mover_der(int *a,int *b,int *x,int *d,int *e,int *z,int *g)
{
gotoxy(*a,*x);
printf(""); //CARITAS DEL CENTRO
gotoxy(*b,*d);
printf("");
gotoxy(*b,*e);
printf(""); //CARITAS DE ARRIBA
gotoxy(*b,*z);
printf("");
gotoxy(*b,*g);
printf(""); //CARITAS DE ABAJO
}
void mover_arriba(int *a,int *b,int *x,int *d,int *e,int *z,int *g)
{
gotoxy(*a,*x);
printf(""); //CARITAS DEL CENTRO
gotoxy(*b,*d);
printf("");
gotoxy(*b,*e);
printf(""); //CARITAS DE ARRIBA
gotoxy(*b,*z);
printf("");
gotoxy(*b,*g);
printf(""); //CARITAS DE ABAJO
}
void mover_abajo(int *a,int *b,int *x,int *d,int *e,int *z,int *g)
{
gotoxy(*a,*x);
printf(""); //CARITAS DEL CENTRO
gotoxy(*b,*d);
printf("");
gotoxy(*b,*e);
printf(""); //CARITAS DE ARRIBA
gotoxy(*b,*z);
printf("");
gotoxy(*b,*g);
printf(""); //CARITAS DE ABAJO
}
void instrucciones (void)
{
gotoxy(10,60);
printf("--------------------------------\n");
gotoxy(10,61);
printf("Presiona la tecla 'Esc' para salir\n");
gotoxy(10,62);
printf("Presiona arriba, abajo, izquierda, derecha para mover\n");
gotoxy(10,60);
printf("----------------------------------");
getch();
clrscr();
}