animation – Programmerbay https://programmerbay.com A Tech Bay for Tech Savvy Sun, 21 Aug 2022 07:04:14 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://programmerbay.com/wp-content/uploads/2019/09/cropped-without-transparent-32x32.jpg animation – Programmerbay https://programmerbay.com 32 32 C Program to Show a Man Walking in Rain https://programmerbay.com/program-for-man-walking-in-rain/ https://programmerbay.com/program-for-man-walking-in-rain/#respond Thu, 11 Aug 2022 17:21:02 +0000 https://www.programmerbay.com/?p=2101 Using translation transformation,  an illusion of moving object can be achieved.  Here’s the simple code to show a man is walking in the rain.

C program for a man walking in the rain

Program:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
void main(){
int gr=DETECT,gm;
int i,x,y,j;
initgraph(&gr,&gm,"C:\\TURBOC3\\BGI");

// man
for(j=1;j<600;j=j+5)
{
line(0,400,800,400);
circle(30+j,280,20); //head
line(30+j,300,30+j,350); //body
line(30+j,330,70+j,330); //hand
if(j%2==0){
line(30+j,350,25+j,400); //left leg
line(30+j,350,10+j,400); // right
}
else{
line(30+j,350,35+j,400); //transition
delay(20);
}
//umbrela
line(70+j,250,70+j,330);
pieslice(70+j,250,180,0,80);
// rain
for(i=0;i<300;i++)
{
x=random(800);
y=random(800);
outtextxy(x,y,"/");
}
delay(170);
cleardevice();
}
getch();
closegraph();
}

 

Output

]]>
https://programmerbay.com/program-for-man-walking-in-rain/feed/ 0