The program should in C lanaguage and also related to Graphics designing.
Write a c program to simulate the movement of a caer?
I have this program on boat race. Take logic and have it as you desire.
#include%26lt;graphics.h%26gt;
#include%26lt;stdio.h%26gt;
#include%26lt;dos.h%26gt;
#include%26lt;math.h%26gt;
int b1,b2,b3,b4,b5,b6,j1=0,i1=0,i=DETECT,j,k...
FILE *fp;
char name[15];
void hai(int,int);
void main()
{
if(fopen("scores.txt","r")==NULL)
{
fp=fopen("scores.txt","w");
fprintf(fp,"0 0 0 0 0 0");
}
initgraph(%26amp;i,%26amp;j,"c:\\tc\\bgi");
setcolor(5);
settextstyle(1,0,6);
outtextxy(40,150,"welcome to boat race");
outtextxy(40,174,"----------------");
getch();
textmode(0);
textcolor(2);
cprintf("enter your name::");
cscanf("%s",%26amp;name);
printf("\n\n");
cprintf(" hai %s welcome to boat race",name);
printf("\n\n\n");
textcolor(14);
cprintf(" records of boats");
table();
printf("\n\n\n\n");
cprintf("see records and select a boat");
printf("\n\n");
cprintf("enter the boat no.::");
cscanf("%d",%26amp;n);
getch();
i=0;
initgraph(%26amp;i,%26amp;j,"c:\\tc\\bgi");
setcolor(14);
rectangle(1,1,getmaxx(),getmaxy());
rectangle(7,7,getmaxx()-7,getmaxy()-7)...
setfillstyle(1,2);
floodfill(6,6,14);
settextstyle(7,0,3);
outtextxy(23,23,"enter any key to start the game. . . . . . . . .");
while(j1!=1)
{i1++;
if(kbhit())
j1=1;}
getch();
j1=abs(i1);
setcolor(0);
settextstyle(7,0,3);
outtextxy(23,23,"enter any key to start the game. . . . . . . . .");
setcolor(15);
circle(500,55,30);
setfillstyle(1,14);
floodfill(500,55,15);
for(i=0;i%26lt;550;i++)
hai(i,j1);
getch();}
void hai(int i,int j1)
{int l;
for(j=0;j%26lt;251;j+=50)
{if(j==0)
{if((b1%26gt;180%26amp;%26amp;b1%26lt;240))
b1+=1;
else if(b1%26gt;250%26amp;%26amp;b1%26lt;400)
b1+=3;
else if((j1%8)%2==0)
b1+=(j1%8+1);
else
b1+=(j1%8);
i=b1;}
else if(j==50)
{if(b2%26gt;100%26amp;%26amp;b2%26lt;200)
b2+=5;
else if(b2%26gt;300%26amp;%26amp;b2%26lt;400)
b2+=5;
else if((j1%3)%2==0)
b2+=(j1%3+1);
else
b2+=j1%3;
i=b2;}
else if(j==100)
{if(b3%26gt;100%26amp;%26amp;b3%26lt;150)
b3+=3;
else if(b3%26gt;150%26amp;%26amp;b3%26lt;300)
b3+=5;
else if((j1%4)%2==0)
b3+=(j1%4+1);
else
b3+=j1%4;
i=b3;}
else if(j==150)
{if(b4%26gt;100%26amp;%26amp;b4%26lt;200)
b4+=3;
else if(b4%26gt;300%26amp;%26amp;b4%26lt;400)
b4+=3;
else if((j1%5)%2==0)
b4+=(j1%5+1);
else
b4+=j1%5;
i=b4;}
else if(j==200)
{if(b1%26gt;200%26amp;%26amp;b4%26lt;400)
b5+=3;
else if(b2%26gt;100%26amp;%26amp;b3%26lt;200)
b5+=3;
else if((j1%6)%2==0)
b5+=(j1%6+1);
else
b5+=j1%6;
i=b5;}
else if(j==250)
{if(b2%26gt;50%26amp;%26amp;b3%26lt;300)
b6+=1;
else if(b1%26gt;150%26amp;%26amp;b4%26lt;300)
b6+=3;
else if((j1%7)%2==0)
b6+=(j1%7+1);
else
b6+=j1%7;
i=b6;}
setcolor(2);
line(8,180+j,630,180+j);
setcolor(6);
ellipse(40+i,159+j,180,360,30,20);
setcolor(7);
circle(35+i,159+j,4);
arc(42+i,164+j,180,310,10);
if(i%2==0)
{line(35+i,167+j,48+i,174+j);
line(38+i,167+j,50+i,174+j);
setcolor(14);
line(50+i,170+j,40+i,200+j);}
else
{line(38+i,167+j,30+i,179+j);
line(35+i,167+j,28+i,180+j);
setcolor(14);
line(31+i,170+j,21+i,200+j);}
if(i%26gt;550%26amp;%26amp;i%26lt;560)
{l=10;
k=j;}}
if(l==10)
{setcolor(6);
fp=fopen("scores.txt","r+");
settextstyle(1,0,4);
switch(k/50+1)
{case 1:
outtextxy(30,230,"the winner of the game is 1st boat");
break;
case 2:
outtextxy(30,230,"the winner of the game is 2th boat");
break;
case 3:
outtextxy(30,230,"the winner of the game is 3th boat");
break;
case 4:
outtextxy(30,230,"the winner of the game is 4th boat");
break;
case 5:
outtextxy(30,230,"the winner of the game is 5th boat");
break;
case 6:
outtextxy(30,230,"the winner of the game is 6th boat");
}
if(n==(k/50+1))
outtextxy(30,270,"congrats ! you have won the match");
else
outtextxy(30,270,"sorry ! you have lost the match");
fseek(fp,(k/50)*12,0);
fscanf(fp,"%d",%26amp;c);
c+=1;
if(c%26gt;=10)
c=0;
fseek(fp,(k/50)*12,0);
fprintf(fp,"%d",c);
fclose(fp);
getch();
cleardevice();
exit(0);}
for(k=0;k%26lt;4;k++)
delay(2000000);
for(j=0;j%26lt;251;j+=50)
{if(j==0)
i=b1;
else if(j==50)
i=b2;
else if(j==100)
i=b3;
else if(j==150)
i=b4;
else if(j==200)
i=b5;
else if(j==250)
i=b6;
setcolor(0);
ellipse(40+i,159+j,180,360,30,20);
circle(35+i,159+j,4);
arc(42+i,164+j,180,310,10);
if(i%2==0)
{line(35+i,167+j,48+i,174+j);
line(38+i,167+j,50+i,174+j);
line(50+i,170+j,40+i,200+j);}
else
{line(38+i,167+j,30+i,179+j);
line(35+i,167+j,28+i,180+j);
line(31+i,170+j,21+i,200+j);}}}
table()
{
fp=fopen("scores.txt","r+");
for(j=0;j%26lt;7;j++)
for(i=10;i%26lt;15;i++)
{gotoxy(4+j*5,i);
cprintf("%c",'³');}
for(j=9;j%26lt;=15;j+=3)
for(i=4;i%26lt;35;i++)
{gotoxy(i,j);
cprintf("%c",'Ä');}
for(i=0;i%26lt;7;i+=3)
for(j=0;j%26lt;7;j++)
{gotoxy(4+j*5,9+i);
if(j==0)
cprintf("%c",'Ã');
else if(j==6)
cprintf("%c",'´');
else
cprintf("%c",'Å');}
for(i=0;i%26lt;6;i++)
{gotoxy(5+i*5,10);
printf("boat");
gotoxy(6+i*5,11);
printf("%d",i+1);
fseek(fp,i*12,0);
fscanf(fp,"%d",%26amp;c);
gotoxy(6+i*5,13);
printf("%d",c);}
getch();
}
visit us :: ebizwebbiz.com/mahesh_naidu/
ebizwebbiz.com/kchandureddy/
thank u
from
Indian
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment