#include "stdlib.h"
#include "graphics.h"
#include "conio.h"
#include "stdio.h"
#include "dos.h"
void main()
{
int gdrive=DETECT,gmode;
static int startx=100;
static int starty=50;
int maxx,maxy;
int x,y,ulx,uly,lrx,lry,size,i,width,height,step;
void *image;
initgraph(&gdrive,&gmode,"D:\\TC\\BGI");
setcolor(CYAN);
rectangle(startx,starty,startx+20,starty+10);
rectangle(startx-5,starty+10,startx+25,starty+16);
circle(startx,starty+19,3);
circle(startx+20,starty+19,3);
maxx=getmaxx();
maxy=getmaxy();
setfillstyle(SOLID_FILL,GREEN);
floodfill(startx+1,starty+11,CYAN);
setfillstyle(SOLID_FILL,RED);
floodfill(startx,starty+19,CYAN);
floodfill(startx+20,starty+19,CYAN);
ulx=startx-5;
uly=starty;
lrx=startx+25;
lry=starty+22;
width=lrx-ulx+1;
height=lry-uly+1;
size=imagesize(ulx,uly,lrx,lry);
getimage(ulx,uly,lrx,lry,image);
putimage(ulx,uly,image,XOR_PUT);
x=maxx/2;
y=maxy/2;
while (!kbhit())
{
putimage(x,y,image,XOR_PUT);
delay(300);
putimage(x,y,image,XOR_PUT);
step=random(6);
if ((step/2) % 2!=0)
step=-1*step;
x+=step;
step=random(3);
if ((step/2) % 2!=0)
step=-1*step;
y+=step;
if ((x+width-1)>maxx)
x=maxx-width+1;
else
if (x<0)
x=0;
if ((y+height-1)>maxy)
y=maxy-height+1;
else
if (y<0)
y=0;
}
free(image);
getch();
closegraph();
}
#include "graphics.h"
#include "conio.h"
#include "stdio.h"
#include "dos.h"
void main()
{
int gdrive=DETECT,gmode;
static int startx=100;
static int starty=50;
int maxx,maxy;
int x,y,ulx,uly,lrx,lry,size,i,width,height,step;
void *image;
initgraph(&gdrive,&gmode,"D:\\TC\\BGI");
setcolor(CYAN);
rectangle(startx,starty,startx+20,starty+10);
rectangle(startx-5,starty+10,startx+25,starty+16);
circle(startx,starty+19,3);
circle(startx+20,starty+19,3);
maxx=getmaxx();
maxy=getmaxy();
setfillstyle(SOLID_FILL,GREEN);
floodfill(startx+1,starty+11,CYAN);
setfillstyle(SOLID_FILL,RED);
floodfill(startx,starty+19,CYAN);
floodfill(startx+20,starty+19,CYAN);
ulx=startx-5;
uly=starty;
lrx=startx+25;
lry=starty+22;
width=lrx-ulx+1;
height=lry-uly+1;
size=imagesize(ulx,uly,lrx,lry);
getimage(ulx,uly,lrx,lry,image);
putimage(ulx,uly,image,XOR_PUT);
x=maxx/2;
y=maxy/2;
while (!kbhit())
{
putimage(x,y,image,XOR_PUT);
delay(300);
putimage(x,y,image,XOR_PUT);
step=random(6);
if ((step/2) % 2!=0)
step=-1*step;
x+=step;
step=random(3);
if ((step/2) % 2!=0)
step=-1*step;
y+=step;
if ((x+width-1)>maxx)
x=maxx-width+1;
else
if (x<0)
x=0;
if ((y+height-1)>maxy)
y=maxy-height+1;
else
if (y<0)
y=0;
}
free(image);
getch();
closegraph();
}