-1
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void base()
{
int k,l;
for(k=0;k<20;l=l+16,k++)
{
rectangle(100+l,400,116+l,418); //square box
line(107+l,418,107+l,413); //middle down to up line
line(107+l,413,100+l,409); //middle to left side
line(107+l,413,112+l,400); //middle to up side
rectangle(100+l,418,116+l,436);
line(107+l,436,107+l,431);
line(107+l,431,100+l,427);
line(107+l,431,112+l,418);
}
}
int main()
{
int gd=DETECT,gm;
int i,j,k,l,ch1,ch2,x=90,y=389;
initgraph(&gd,&gm,"c:\\tc\\bgi");
//base();
ch1=getch();
while(ch1==32)
{
base();
if(ch1!=32)
return 0;
ch2=getch();
if(ch2!=97&&ch2!=119&&ch2!=100)
return 0;
switch(ch2)
{
case 97:
cleardevice();
x=x+5;
if(x==100)//if(x==150&&y==100)
circle(x,y+18,10);//y=y+18;
break;
case 119:
cleardevice();
for(j=1;j<11;j++)
{
base();
delay(100);
cleardevice();
if(j==1||j==2||j==3||j==5||j==6||j==7||j==9||j==10)
{
//base();
//cleardevice();
x=x+1;
}
y=y-1;
circle(x,y,10);
//base();
}
for(i=1;i<11;i++)
{
base();
delay(100);
cleardevice();
if(j==1||j==2||j==3||j==5||j==6||j==7||j==9||j==10)
{
//cleardevice();
x=x+1;
}
y=y+1;
circle(x,y,10);
}
break;
case 100:
cleardevice();
x=x-5;
break;
}
circle(x,y,10);
}
ch1=getch();
getch();
closegraph();
return 0;
}

Edited by naveen1993

2
Contributors
2
Replies
32
Views
3 Years
Discussion Span
Last Post by naveen1993
0

So what specifically are you trying to do and what is it not doing that you are expecting or what is it doing that you are not expecting?

0

actually when iam executing and running this program, if pressed w key the bricks also moving forward wihle the circle is moving up. When it is coming down (circle) no effect in that code....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.