this program is working fine..
As i was moving the object with the help of ASCII values.
But i want to move the object towards right as per my input (through keyboard,right arrow).
But it is moving with the same x and y axis..

#include<stdio.h>
#include<conio.h>
#include <graphics.h>
int j;
void person(int p,int q,int r)
{
setcolor(RED);
line(100+p-q,100-r,115+p-q,100-r); //top line
line(100+p-q,100-r,100+p-q,105-r); //line b/w hat and top line left side
line(115+p-q,100-r,115+p-q,105-r); //line b/w hat and top line right side
rectangle(95+p-q,105-r,120+p-q,108-r); //hat
line(99+p-q,108-r,99+p-q,119-r); //face left side
line(117+p-q,108-r,117+p-q,119-r); //face right side
arc(108+p-q,119-r,180,360,8); //face down arc
circle(104+p-q,113-r,1); //left eye
circle(112+p-q,113-r,1); //right eye
arc(108+p-q,119-r,180,360,2); //smiling
line(99+p-q,119-r,96+p-q,119-r); //left hand shoulder
line(96+p-q,119-r,96+p-q,128-r); //left hand elbow
circle(96+p-q,130-r,2); //left hand palm
line(117+p-q,119-r,120+p-q,119-r); //right hand shoulder
line(120+p-q,119-r,120+p-q,128-r); //right hand elbow
circle(120+p-q,130-r,2); //right hand palm
line(104+p-q,127-r,104+p-q,140-r); //left leg
circle(104+p-q,142-r,2); //left leg foot
line(112+p-q,126-r,112+p-q,140-r); //right leg
circle(112+p-q,142-r,2); //right leg foot
}
int main()
{
int ch1,ch2,gd=DETECT,gm;
int q,p;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
ch1=getch();
while(ch1==32)
{
ch2=getch();
switch(ch2)
{
case 97:  //a->97 left
cleardevice();
person(5,0,0);
break;
case 119: //w->119 up
cleardevice();
person(0,0,10);
break;
case 100: //d->100 right
cleardevice();
person(0,5,0);
break;
default: printf("no");
}
ch1=getch();
}
getch();
closegraph();
return 0;
}

is program is working fine..
As i was moving the object with the help of ASCII values.
But i want to move the object towards right as per my input (through keyboard,right arrow).
But it is moving with the same x and y axis..

This article has been dead for over six months. Start a new discussion instead.