program of baal game catch circles coming down with use left right arrow key
Program
#include
#include
#include
#include
#include
#include
int a,b,ch;
int c=2,d=3;
static char msg[1];
static int chance,pts,x1,x2,y1,y2;
over()
{
int i=0,j,x=185,y=240;
while(i<1000) { j=1+rand()%15; setcolor(j); settextstyle(0,0,4); outtextxy(x,y,"GAME OVER"); delay(100); i++; } exit(1); return; } move(int x1,int x2,int y1,int y2,int k) { int i=0; i=i+10; if(k==1) //left {i=i; bar1(x2-i,x2,y1,y2,2); } else { i=-i; bar1(x1,x1-i,y1,y2,3); } bar1(x1-i,x2-i,y1,y2,1); return; } bar1(int x1,int x2,int y1,int y2,int k) { if(k==1) {c=2; d=3;} else {c=d=0;} setfillstyle(2,d); bar(x1,479-y1,x2,479-y2); return; } keyin() { int i; ch=getch(); switch(ch) { case 75: if(x1>24)
{
i=10; //left
move(x1,x2,y1,y2,1);
x2=x2-i;
x1=x1-i;
}
break;
case 77: //right
if(x2<614) { i=10; move(x1,x2,y1,y2,2); x1=x1+i; x2=x2+i; } break; }//end switch if(ch==27) over(); return; } ball() { int a,b,t=0; a=639-rand()%639; b=350; while(b>100)
{
b=b-1;
setcolor(RED);
if((a-5)<=x2&&(a+5)>=x1&&(479-(b-5)>=(479-y1))&&(479-(b+5)<=(479-y2)))
{score();
t=1;
break;}
if(kbhit())
keyin();
circle(a,479-b,5);
delay(10);
setcolor(BLACK);
circle(a,479-b,5);
}
if(t==0)
chance++;
if(chance==2)
over();
return;
}
score()
{
setcolor(0);
settextstyle(0,0,5);
sprintf(msg,"%d",pts);
outtextxy(110,20,msg);
setcolor(4);
sound(1100);
delay(50);
nosound();
pts++;
settextstyle(0,0,5);
sprintf(msg,"%d",pts);
outtextxy(110,20,msg);
return;
}
play()
{
while(ch!=27)
ball();
return;
}
Program
#include
#include
#include
#include
#include
#include
int a,b,ch;
int c=2,d=3;
static char msg[1];
static int chance,pts,x1,x2,y1,y2;
over()
{
int i=0,j,x=185,y=240;
while(i<1000) { j=1+rand()%15; setcolor(j); settextstyle(0,0,4); outtextxy(x,y,"GAME OVER"); delay(100); i++; } exit(1); return; } move(int x1,int x2,int y1,int y2,int k) { int i=0; i=i+10; if(k==1) //left {i=i; bar1(x2-i,x2,y1,y2,2); } else { i=-i; bar1(x1,x1-i,y1,y2,3); } bar1(x1-i,x2-i,y1,y2,1); return; } bar1(int x1,int x2,int y1,int y2,int k) { if(k==1) {c=2; d=3;} else {c=d=0;} setfillstyle(2,d); bar(x1,479-y1,x2,479-y2); return; } keyin() { int i; ch=getch(); switch(ch) { case 75: if(x1>24)
{
i=10; //left
move(x1,x2,y1,y2,1);
x2=x2-i;
x1=x1-i;
}
break;
case 77: //right
if(x2<614) { i=10; move(x1,x2,y1,y2,2); x1=x1+i; x2=x2+i; } break; }//end switch if(ch==27) over(); return; } ball() { int a,b,t=0; a=639-rand()%639; b=350; while(b>100)
{
b=b-1;
setcolor(RED);
if((a-5)<=x2&&(a+5)>=x1&&(479-(b-5)>=(479-y1))&&(479-(b+5)<=(479-y2)))
{score();
t=1;
break;}
if(kbhit())
keyin();
circle(a,479-b,5);
delay(10);
setcolor(BLACK);
circle(a,479-b,5);
}
if(t==0)
chance++;
if(chance==2)
over();
return;
}
score()
{
setcolor(0);
settextstyle(0,0,5);
sprintf(msg,"%d",pts);
outtextxy(110,20,msg);
setcolor(4);
sound(1100);
delay(50);
nosound();
pts++;
settextstyle(0,0,5);
sprintf(msg,"%d",pts);
outtextxy(110,20,msg);
return;
}
play()
{
while(ch!=27)
ball();
return;
}
No comments:
Post a Comment
Thanks to given comments.......