#include #include #include #include #include #include void score(int i) { setcolor(10); settextstyle(2,0,1); outtextxy(25+i+5,(getmaxy())-25,"*"); } void erase(int x) { setcolor(9); settextstyle(2,0,1); outtextxy(25+x+5,(getmaxy())-25,"*"); } void main() { /* select a driver and mode that supports */ /* multiple background colors. */ int gdriver = EGA, gmode = EGAHI, errorcode; int poly1[20],poly2[20],i,j,k,m=0,n=225,x,y,z,p; int poly[20],a=0,b,s=0; char ch,ans='y',msg[80]; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } /* for centering text messages */ settextjustify(CENTER_TEXT, CENTER_TEXT); x = getmaxx();// / 2; y = getmaxy();// / 2; setbkcolor(9); getch(); /*score board*/ setcolor(12); rectangle(5,y-55,105,y-5); rectangle(8,y-52,102,y-8); settextstyle(1,0,1); outtextxy(55,y-45,"SCORE"); /*name*/ settextstyle(2,0,4); outtextxy(x/2,y-10,"BY ARUN PRASANTH.B I-year ECE"); while(ans=='y') { /*bow*/ j=5; i=5; setcolor(14); arc(5,25,315,45,45); line(5,25,39,3); line(5,25,39,47); setcolor(9); line(39,3,39,47); line(50,24,50,26); a=0; m=0; n=225; s=0; for(p=5;p<65;p=p+5) { erase(p); } while(a<10) { poly[0]=i+2; poly[1]=m+25; poly[2]=i; poly[3]=m+24; poly[4]=i+55; poly[5]=m+24; poly[6]=i+50; poly[7]=m+20; poly[8]=i+60; poly[9]=m+25; poly[10]=i+50; poly[11]=m+30; poly[12]=i+55; poly[13]=m+26; poly[14]=i; poly[15]=m+26; poly[16]=i+2; poly[17]=m+25; setcolor(4); setfillstyle(1,4); fillpoly(9,poly); m=m+25; a++; } /*baloon*/ setcolor(10); setfillstyle(1,10); fillellipse(x-50,y-50,15,20); b=10; //getch(); while(b>0) { setcolor(4); setfillstyle(1,4); i=5; poly[0]=i+2; poly[1]=25; poly[2]=i; poly[3]=24; poly[4]=i+55; poly[5]=24; poly[6]=i+50; poly[7]=20; poly[8]=i+60; poly[9]=25; poly[10]=i+50; poly[11]=30; poly[12]=i+55; poly[13]=26; poly[14]=i; poly[15]=26; poly[16]=i+2; poly[17]=25; fillpoly(9,poly); setcolor(14); line(5,25,39,3); line(5,25,39,47); for(k=y-50;k>0&&(!kbhit());k--) { setcolor(10); setfillstyle(1,10); fillellipse(x-50,k,15,20); delay(15); setcolor(9); setfillstyle(1,9); fillellipse(x-50,k,20,20); } j=5; if(k==0&&b==1) { setcolor(9); line(5,25,39,3); line(5,25,39,47); setcolor(14); line(39,3,39,47); line(50,24,50,26); } else if(k==0) { setcolor(4); setfillstyle(1,4); fillpoly(9,poly); } else { for(i=5,z=k;i0;z--,i=i+5) { //if(z==0) //break; if(j<35) { setcolor(14); line(j,25,39,3); line(j,25,39,47); } if(j==35) { setcolor(14); line(39,3,39,47); line(50,24,50,26); } setcolor(4); setfillstyle(1,4); //m=0; poly[0]=i+2; poly[1]=25; poly[2]=i; poly[3]=24; poly[4]=i+55; poly[5]=24; poly[6]=i+50; poly[7]=20; poly[8]=i+60; poly[9]=25; poly[10]=i+50; poly[11]=30; poly[12]=i+55; poly[13]=26; poly[14]=i; poly[15]=26; poly[16]=i+2; poly[17]=25; fillpoly(9,poly); setcolor(10); setfillstyle(1,10); fillellipse(x-50,z,15,20); delay(15); if(j<35) { setcolor(9); line(j,25,39,3); line(j,25,39,47); j++; } //burst if(poly[8]>=x-70&&poly[8]=10) { setcolor(9); setfillstyle(1,9); fillellipse(x-50,z,20,20); setcolor(10); setfillstyle(1,10); poly1[0]=x-70; poly1[1]=z+5; poly1[2]=x-50; poly1[3]=z-10; poly1[4]=x-30; poly1[5]=z+5; poly1[6]=x-70; poly1[7]=z+5; poly2[0]=x-70; poly2[1]=z-5; poly2[2]=x-30; poly2[3]=z-5; poly2[4]=x-50; poly2[5]=z+10; poly2[6]=x-70; poly2[7]=z-5; fillpoly(4,poly1); fillpoly(4,poly2); s=s+5; delay(5); score(s); setcolor(9); setfillstyle(1,9); fillpoly(4,poly1); fillpoly(4,poly2); fillpoly(9,poly); break; } setcolor(9); setfillstyle(1,9); fillpoly(9,poly); fillellipse(x-50,z,20,20); line(39,3,39,47); line(50,24,50,26); } } setcolor(9); setfillstyle(1,9); fillellipse(x-50,z,20,20); line(39,3,39,47); line(50,24,50,26); i=5; poly[0]=i+2; poly[1]=n+25; poly[2]=i; poly[3]=n+24; poly[4]=i+55; poly[5]=n+24; poly[6]=i+50; poly[7]=n+20; poly[8]=i+60; poly[9]=n+25; poly[10]=i+50; poly[11]=n+30; poly[12]=i+55; poly[13]=n+26; poly[14]=i; poly[15]=n+26; poly[16]=i+2; poly[17]=n+25; delay(10); fillpoly(9,poly); n=n-25; b--; fflush(stdin); getch(); }//end of 1 game setcolor(14); line(39,3,39,47); line(50,24,50,26); setcolor(14); settextstyle(2,0,4); outtextxy(x/2,y/2,"Continue y/n"); ans=getch(); setcolor(9); settextstyle(2,0,4); outtextxy(x/2,y/2,"Continue y/n"); } //clean up getch(); restorecrtmode(); closegraph(); }