Draw The Walking Man On The Screen Program In C | BGI | VCMIT

Draw The Walking Man On The Screen Program In C


INPUT

#include<stdio.h>
#include<graphics.h>
#define ScreenWidth getmaxx()
#define ScreenHeight getmaxy()
#define GroundY ScreenHeight*0.75
int ldaisp=0;
void DrawManWithUmbrella(int a,int ldaisp)
{
//Draw Umbrella
pieslice(a+20,GroundY-120,0,180,40);
line(a+20,GroundY-120,a+20,GroundY-70);
//Draw head
circle(a,GroundY-90,10);
line(a,GroundY-80,a,GroundY-30);
//Draw hand
line(a,GroundY-70,a+10,GroundY-60);
line(a,GroundY-65,a+10,GroundY-55);
line(a+10,GroundY-60,a+20,GroundY-70);
line(a+10,GroundY-55,a+20,GroundY-70);
//Draw legs
line(a,GroundY-30,a+ldaisp,GroundY);
line(a,GroundY-30,a-ldaisp,GroundY);
}
void Rain(int a)
{
int i,rx,ry;
for(i=0;i<400;i++)
{
rx=rand() % ScreenWidth;
ry=rand() % ScreenHeight;
if(ry<GroundY-4)
{
if(ry<GroundY-120 || (ry>GroundY-120 && (rx<a-20 || rx>a+60)))
line(rx,ry,rx+0.5,ry+4);
}
}
}
void main()
{
int gd=DETECT,gm,a=0;
initgraph(&gd,&gm,"C:\\TC\\BGI");

while(!kbhit())
{
//Draw Ground
line(0,GroundY,ScreenWidth,GroundY);
Rain(a);
ldaisp=(ldaisp+2)%20;
DrawManWithUmbrella(a,ldaisp);
delay(40);
cleardevice();
a=(a+2)%ScreenWidth;
}
getch();
}

OUTPUT





Disqus Comments
TheWaoFam. يتم التشغيل بواسطة Blogger.

إجمالي مرات مشاهدة الصفحة

بحث هذه المدونة الإلكترونية

  • ()

Random Posts

randomposts

Recent Posts

recentposts

Footer Link

Connected

Facebook

banner image

Most Recent

نموذج الاتصال

Categories

There are many variations of passages of Lorem Ipsum available.

About Me

Hi there, I’m Amanda – a girl love fashion and love to express herself with her own sense of style.

Trending