GET KTU B.TECH RESULTS ON MAIL

Subscribe to our mailing list and get KTU results in your mail box. CLICK HERE

MAN WALKING IN THE RAIN WITH AN UMBRELLA - Computer Graphics Lab Program in C Programming Language

Computer Graphics Lab Program in C Programming Language- MAN WALKING IN THE RAIN WITH AN UMBRELLA

AIM
Write a C program to show the animation of a man walking in the rain with an umbrella.

ALGORITHM
Step 1: Start
Step 2: Draw a man using the line function and sector function.
Step 3: Draw the rain.
Step 4: Provide motion to the man in the horizontal axis.
Step 5: Repeat the step 2 until kbhit()
Step 6: Stop

PROGRAM
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
void main()
{inti,x,y,rj,rhx,rhy,j,k;
intgd=DETECT,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"d:\\tc\\bgi");
for(i=0;i<100;i++)
{
line(0,265,600,265);
line(0,275,600,275);
line(10,270,13,275);

line(13,275,16,270);
line(19,270,22,275);
line(22,275,25,270);
line(27,270,30,275);
line(30,275,33,270);
line(35,270,38,275);
line(38,275,41,270);
line(44,270,47,275);
line(47,275,50,270);
line(52,270,55,275);
line(55,275,58,270);
line(60,270,63,275);
line(63,275,66,270);
line(68,270,71,275);
line(71,275,74,270);
line(52,270,55,275);
line(55,275,58,270);
circle(250+i,120,25);
setcolor(5);
circle(260+i,115,2.5);
setcolor(5);
circle(240+i,115,2.5);
setcolor(5);
line(243+i,132,255+i,132);
setcolor(4);
line(250+i,146,250+i,225);
setcolor(5);
line(245+i,226,256+i,226);
setcolor(5);
line(245+i,226,245+i,274);
setcolor(5);
line(256+i,226,256+i,274);
setcolor(5);
line(245+i,274,242+i,274);

setcolor(5);
line(256+i,274,260+i,274);
setcolor(5);
line(245+i,158,256+i,158);
setcolor(5);
line(245+i,158,235+i,188);
setcolor(5);
line(235+i,188,232+i,188);
setcolor(5);
line(256+i,158,266+i,188);
setcolor(5);
line(266+i,188,269+i,188);
setcolor(5);
line(269+i,188,280+i,90);
setcolor(5);
line(218+i,90,315+i,90);
setcolor(5);
arc(265+i,125,37,140,60);
setcolor(5);
circle(267+i,188,3);
setcolor(5);
rhx=getmaxx();
rhy=getmaxy();
for(j=0;j<100;j++)
{
outtextxy(random(rhx),random(rhy-50),"|");
setcolor(WHITE);
}
delay (60);
cleardevice();
}
getch();

}

OUTPUT
MAN WALKING IN THE RAIN WITH AN UMBRELLA - Computer Graphics Lab Programs in C Programming Language
MAN WALKING IN THE RAIN WITH AN UMBRELLA 
Previous
Next Post »