#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void gotoxy(int y,int x)
{
COORD scrn;
HANDLE hOuput=GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X=x;scrn.Y=y;
SetConsoleCursorPosition(hOuput,scrn);
}
void put(int n,char ch)
{
for(int i=0;i<n;i++)
printf("%c",ch);
}
int height=20;int width=60;
void face()
{
gotoxy(5,5);
put(width,'*');
for(int j=0;j<height;j++)
{
gotoxy(6+j,5);
printf("*");
}
gotoxy((height+5),5);
put(width,'*');
for(int n=0;n<height;n++)
{
gotoxy(6+n,width+4);
printf("*\n");
}
}
void ball(int x,int y,int xp,int yp)
{
while(1)
{
gotoxy(y,x);
printf("o");
Sleep(200);
gotoxy(y,x);
printf(" ");
x+=xp;
y+=yp;
if(x>width+2||x<7)
xp=-xp;
if(y>height+3||y<7)
yp=-yp;
if(x>=width+2)
x=width+2;
if(y>height+4)
y=height+4;
if(x<=7)
x=7;
if(y<6)
y=6;
}
}
main()
{
face();
ball(8,13,2,3);
ball(12,10,4,1);
}