VIBORA.c



#include<graphics.h>
#include <stdio.h>

int x, y;

void Inicia( )
{
	char Tecla=' ';
	int Dir = 0, N=50;

	x = getmaxx( ) /2;
	y = getmaxy( ) /2;
	printf("OK");
	while ( N != 0 )
	{
		//cleardevice();
		fillellipse(x, y, 5, 5);
		//Tecla=getchar(); Tecla=getchar(); Tecla=getchar();
		Dir = rand( ) % 5;
		Tecla = Dir + 64;
		printf("T=%d\tX=%d\tY=%d\n",Tecla,x,y);
		if (Tecla == 65)  { y=y-10; if ( !y ) y=0; }					// arriba
		if (Tecla == 66)  { y=y+10; if ( y>getmaxy( ) ) y=getmaxy( ); }		// abajo
		if (Tecla == 67)  { x=x+10; if ( x>getmaxx( ) ) x=getmaxx( ); }		// derecha
		if (Tecla == 68)  { x=x-10; if ( !x ) x=0; }						// izquierda

		delay(100);
		N--;
	}
}


// int initwindow(int width, int height, const char* title="Windows BGI", int left=0, int top=0, bool dbflag=false, closeflag=true);

int main()
{
	int gd = DETECT,gm;
	initgraph(&gd,&gm,NULL);
	Inicia( );
	closegraph();
}