Walking Man

#include<stdio.h>
#include<conio.h>
#include<graphics.h>

void man(int,int);

void main()
{
    int gd=DETECT,gm,x=400,y=400;
    char k;
    clrscr();
    initgraph(&gd,&gm,"c:\\TURBOC3\\BGI");
    printf("Running in the wild !!\n");
    printf("Use w,a,s,d for Controlls and f to Exit.");
    do
    {
        man(x,y);
        k=getch();
        switch(k)
        {
            case 'w':
                y=y-10;
                break;
            case 'a':
                x=x-10;
                break;
            case 's':
                y=y+10;
                break;
            case 'd':
                x=x+10;
                break;
        }
        cleardevice();
    }while(k!='f');
    closegraph();
    getch();
}

void man(int x,int y)
{
    line(x,y,x,y+50);
    circle(x,y-15,15);
    line(x,y+30,x+20,y);
    line(x,y+30,x-20,y);
    line(x,y+50,x+10,y+80);
    line(x,y+50,x-10,y+80);
}

Output
1

2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s