#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<graphics.h>
#include<stdlib.h>
void raindrops();
void far *man1,*man2;
unsigned size1,size2;
int cx=15,cy=360,r=22;
int x=0,y,p,i;
void drawgrass()
{
setfillstyle(3,GREEN);
bar(0,385,getmaxx(),getmaxy());
}
void drawmanbody()
{
fillellipse(15,350,7,7);
moveto(15,350);
lineto(15,370);
lineto(25,360);
lineto(25,369);
lineto(15,370);
lineto(15,390);
lineto(15,390);
lineto(15,390);
}
void drawman1()
{
drawmanbody();
rectangle(23,369,28,400);
setfillstyle(SOLID_FILL,RED);
floodfill(24,370,WHITE);
size1=imagesize(0,299,30,416);
man1=malloc(size1);
getimage(0,299,30,416,man1);
setfillstyle(SOLID_FILL,WHITE);
cleardevice();
}
void drawman2()
{
drawmanbody();
moveto(25,369);
lineto(25,340);
line(5,340,41,340);
arc(23,340,0,180,18);
setfillstyle(SOLID_FILL,RED);
floodfill(24,339,WHITE);
size2=imagesize(0,249,42,416);
man2=malloc(size2);
getimage(0,299,42,410,man2);
cleardevice();
}
void raindrops()
{
int x,x1,y1;
setcolor(15);
x=getmaxx();
x1=random(x);
y1=random(480);
line(x1,y1,x1+5,y1+5);
}
int path1(int dtn)
{
int x1,y1;
setcolor(15);
if(x>=y)
{
return 0;
}
cleardevice();
if(dtn==1)
{
putimage(++i,270,man2,COPY_PUT);
raindrops();
drawgrass();
line(cx+i,cy,cx+x+i,cy+y);
line(cx+i,cy,cx-x+i,cy+y);
}
else
{
putimage(++i,270,man2,COPY_PUT);
raindrops();
drawgrass();
line(cx+i,cy,cx-x+i,cy+y);
line(cx+i,cy,cx+x+i,cy+y);
}
delay(50);
if(kbhit())
exit(0);
x++;
if(p<0)
p+=2*x+1;
else
{
y--;
p+=2*(x-y)+1;
}
x1=x;
y1=y;
path1(dtn);
cleardevice();
if(dtn==1)
{
putimage(++i,270,man2,COPY_PUT);
raindrops();
drawgrass();
line(cx+i,cy,cx+x1+i,cy+y1);
line(cx+i,cy,cx-x1+i,cy+y1);
}
else
{
putimage(++i,270,man2,COPY_PUT);
raindrops();
drawgrass();
line(cx+i,cy,cx-x1+i,cy+y1);
line(cx+i,cy,cx+x1+i,cy+y1);
}
delay(50);
if(kbhit())
exit(0);
return(0);
}
int path(int dtn)
{
int x1,y1;
setcolor(15);
if(x>=y)
{
return 0;
}
if(dtn==1)
{
putimage(++i,270,man1,COPY_PUT);
drawgrass();
line(cx+i,cy,cx+x+i,cy+y);
line(cx+i,cy,cx-x+i,cy+y);
}
else
{
putimage(++i,270,man1,COPY_PUT);
drawgrass();
line(cx+i,cy,cx-x+i,cy+y);
line(cx+i,cy,cx+x+i,cy+y);
}
delay(50);
if(kbhit())
exit(0);
x++;
if(p<0)
p+=2*x+1;
else
{
y--;
p+=2*(x-y)+1;
}
x1=x;
y1=y;
path(dtn);
cleardevice();
if(dtn==1)
{
putimage(++i,270,man1,COPY_PUT);
drawgrass();
line(cx+i,cy,cx+x1+i,cy+y1);
line(cx+i,cy,cx-x1+i,cy+y1);
}
else
{
putimage(++i,270,man1,COPY_PUT);
drawgrass();
line(cx+i,cy,cx-x1+i,cy+y1);
line(cx+i,cy,cx+x1+i,cy+y1);
}
delay(100);
if(kbhit())
exit(0);
return(0);
}
void startwalk()
{
double theta;
for(i=0;i<600;)
{
if(i<=100)
{
x=0;
y=r;
p=1-r;
path(1);
x=0;
y=r;
p=1-r;
path(0);
}
else if(i>100 && i<600)
{
x=0;
y=r;
p=1-r;
path1(1);
x=0;
y=r;
p=1-r;
path1(0);
}
}
}
//umbrella program by Fensa Merry Saj
void main()
{
int i,j;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
drawman1();
drawman2();
startwalk();
raindrops();
getch();
}
No comments:
Post a Comment