/************************************************************************/ /* Designed & developed by J.V.RAVICHANDRAN. */ /* Started on 19/04/1998. */ /* Author's name -- J.V.RAVICHANDRAN */ /* Company's name -- Semantix Computers. */ /* Company's address -- B-10, Triveni Apartments, */ /* Vikas puri, New Delhi - 110018. */ /* Completed on -- 27th April, 1998. */ /* Name of software -- GREYcells Bricks */ /* Nature of software -- Game */ /************************************************************************/ #include#include #include #include #include #include #include #include #include #include #include #define ALT 1 #define RESUME 1 int downangle=1,gdriver = VGA, gmode=VGAHI, err_code,time_spent=0,incolor,downevaluateflag=0; int x,y,xx,yy,barx,bary,barxx,baryy,ctr,key,c,r,scorex,ballnum,ballcx; int ballrow,ballcol,ix=1,down,counter,angle=-2,once=0,cx,bricknum=0,key; int menuon,menuflag,menuitem,item,ballcx,wallctr; int menucol,menurow,menucoll,menuroww,brickctr=0,scorectr=0; int delayover=1,textcounter=0,delaytime=20,evaluateflag; int messageboxc,messageboxr,messageboxcc,messageboxrr,midx,soundon=1,hitflag=0; char *brick[40]; char *str[3]; char newstr; void *sbox; unsigned size; int score,ballctr,cursorctr; int seed = 1958,count,color,ccx=10,handle,ct,gamestart=2,goon,sharecounter; int i, vx, vy, h, w, z, q, greateri,bx,bxx,lastcounter,lastballnum,lastballcx; struct viewporttype vp; char terminator,leng; int c_break() { if (gamestart==2 || gamestart==0){ cleardevice(); screen();} nosound(); return (RESUME); } main(){ ctrlbrk(c_break); initgraph(&gdriver, &gmode, ""); #if 0 err_code = graphresult(); if (err_code !=grOk) { printf("Graphic initialization error...\n"); time_spent=0; while (time_spent<50){ time_spent++; delay(25);} exit(0); } #endif ct=access("delaytic.$$$",0); if (ct==-1){ _fmode=O_BINARY; handle=_creat("termtic.$$$", FA_HIDDEN); lseek(handle, 0L, SEEK_SET); _write(handle,"1",1); _close(handle); _fmode=O_BINARY; handle=_creat("delaytic.$$$", FA_HIDDEN); lseek(handle, 0L, SEEK_SET); _write(handle,"1",1); _close(handle); goon=1;} if (ct==0){goon=1;} if (goon==1){ ct=access("termtic.$$$",0); if (ct==-1){
_fmode=O_BINARY;
handle=_creat("termtic.$$$", FA_HIDDEN);
lseek(handle, 0L, SEEK_SET);
_write(handle,"1",1);
_close(handle);
_fmode=O_BINARY;
handle=_creat("delaytic.$$$", FA_HIDDEN);
lseek(handle, 0L, SEEK_SET);
_write(handle,"1",1);
_close(handle);
goon=1;}
if (ct==0){goon=1;}
if (goon==1){
ct=access("termtic.$$$",0);
if (ct==-1){
setfillstyle(SOLID_FILL,15);
bar(100,100,400,200);
setfillstyle(SOLID_FILL,0);
bar(101,101,399,120);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(220,111,"GREYcells");
setcolor(0);
outtextxy(110,135,"Intruder alert ! Please contact");
outtextxy(110,150,"the developer immediately.");
sound(100);
delay(75);
nosound();
getch();
cleardevice();
closegraph();
_close(handle);
ix=0;
exit(0);}
if (ct==0){
handle=open("termtic.$$$", O_RDONLY | O_BINARY);
lseek(handle, 0L, SEEK_SET);
counter=0;
leng=filelength(handle);
sscanf(&terminator,"%d",&leng);
while (!eof(handle)){
read(handle,&terminator,4);}
}
chmod("termtic.$$$",S_IWRITE);
unlink("termtic.$$$");
_fmode=O_BINARY;
handle=_creat("termtic.$$$", FA_HIDDEN);
lseek(handle, 0L, SEEK_SET);
sscanf(&terminator,"%d",&counter);
counter++;
sprintf(&terminator,"%d",counter);
_write(handle,&terminator,4);
if (counter<28){
ix=2;}
if (counter>28){
sound(100);
delay(25);
sound(150);
delay(25);
sound(125);
delay(25);
nosound();
alertformoney();
getch();
cleardevice();
chmod("termtic.$$$",S_IREAD);
_close(handle);
ix=2;
sharecounter=1;}
}
if (ix==2){
screen();}
while (ix==1){
ctrlbrk(c_break);
while (!kbhit()){
if (gamestart==1){
delay(delaytime);
incolor=0;
ball();
if (ballrow<435 && down==1){
ballrow=ballrow+5;}
if (ballrow<435 && down==0){
ballrow=ballrow-5;}
if (ballrow<=0 && down==0){
once=0;
ballrow=0;
downangle=1;
down=1;}
if (ballrow<=100 && down==1 && downangle==1){
once=0;
downevaluateflag=1;
evaluateflag=0;
evaluate();
secondevaluate();
}
if (ballrow<435 && down==4 && downangle!=1){
ballrow=ballrow-5;
downangle=0;}
if (ballrow<=0){
downangle=1;
ballrow=0;}
if (ballrow<=100 && down==1 && downangle==1){
once=0;
downevaluateflag=1;
evaluateflag=0;
evaluate();
secondevaluate();
}
if (ballrow<=100 && down==4 && downangle==1){
once=0;
downevaluateflag=1;
evaluate();}
if (ballrow<=100 && down==4 && downangle==0){
once=0;
evaluateflag=0;
evaluate();
secondevaluate();
}
if (down==7){down=1;}
if (ballrow<=100 && down==3){
once=0;
downevaluateflag=1;
evaluateflag=0;
evaluate();
secondevaluate();
}
if (ballrow>=435 && down==1){
if (soundon==1){
sound(100);
delay(10);
nosound();}
wallctr=0;
bx=x;
bxx=xx;
counter=bx;
downangle=0;
down=6;}
if (ballrow>=435 && down==7){
if (soundon==1){
sound(100);
delay(10); nosound();}
wallctr=0;
bx=x;
bxx=xx;
counter=bx;
downangle=0;
down=6;}
if (down==6){
for (counter==bx;counter=bx-6 && ballcol<=bx+10){
angle=1;
counter=bxx+3;
down=3;}
if (ballcol>bx+10 && ballcol<=bx+20){
angle=2;
counter=bxx+3;
down=3;}
if (ballcol>bx+20 && ballcol<=bx+30){
angle=3;
counter=bxx+3;
down=3;}
if (ballcol>bx+30 && ballcol<=bx+40 && ballcol!=bx+36 && ballcol!=bx+37){
angle=4;
counter=bxx+3;
down=3;}
if (ballcol>bx+40 && ballcol<=bx+50){
angle=5;
counter=bxx+3;
down=3;}
if (ballcol>bx+50 && ballcol<=bx+60){
angle=6;
counter=bxx+3;
down=3;}
if (ballcol>bx+60 && ballcol<=bx+70){
angle=7;
counter=bxx+3;
down=3;}
if (ballcol>bx+70 && ballcol<=bx+83){
angle=8;
counter=bxx+3;
down=3;}
if (ballcol==bx+36 || ballcol==bx+37){
ballrow=ballrow-5;
angle=-1;
down=4;
counter=bxx+3;}
if (down==6){
counter=bxx+3;
down=5;}
}
}
if (down==3){
upangles();}
if (down==5){
if (delayover==3){
cleardevice();
start();
ballrow=125;
ballcol=300;
downangle=1;
gamestart=1;
delayover=5;}
if (delayover!=3 || delayover!=5){
if (soundon==1){
sound(100);
delay(50);
nosound();}
ballrow=ballrow+10;
incolor=9;
ball();
if (ballcx<=135){
setcolor(0);
circle(ballcx,470,7);
ballcx=ballcx+25;
ballnum++;
if (ballnum>4){ballnum=0;}
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(10);
outtextxy(125,250,"Have another ball !");
delay(1500);
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(0);
outtextxy(125,250,"Have another ball !");}
if (ballcx>=150){
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(12);
outtextxy(225,250,"Game over !");
tune();
getch();
setfillstyle(SOLID_FILL,0);
bar(x,y,xx,yy);
incolor=0;
ball();
delay(50);
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(0);
outtextxy(225,250,"Game over !");
score=0;
start();
scorex=510;
score=0;
scorex+=textwidth("Score -");
scorex=scorex+5;
ballcx=10;}
}
if (delayover==5){down=1;}
writescore();
wallctr=0;
incolor=0;
ball();
ballrow=125;
down=1;}
incolor=12;
ball();
}
}
key=getch();
switch(key){
case 32:
if (gamestart==2){
if (menuon==2 && item==1){
sound(100);
delay(50);
nosound();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(15);
soundon++;
if (soundon>1){
soundon=0;}
if (soundon==1){
setcolor(7);
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");
setcolor(15);
outtextxy(menucol+75,menurow+13,"Sound ( ON )");}
if (soundon==0){
setcolor(7);
outtextxy(menucol+75,menurow+13,"Sound ( ON )");
setcolor(15);
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");}
}
}
break;
case ALT==1:
case 129:
if (gamestart==2){
if (menuon==0){
menucol=15;
menurow=14;
menucoll=164;
menuroww=57;
messageboxc=menucol;
messageboxr=menurow;
messageboxcc=menucoll;
messageboxrr=menuroww;
savebox();
dropdownmenu();
setcolor(12); settextstyle(DEFAULT_FONT,VERT_DIR,1); settextjustify(0,1); outtextxy(18,11,"0");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
if (soundon==1){
outtextxy(menucol+75,menurow+13,"Sound ( ON )");}
if (soundon==0){
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");}
outtextxy(menucol+75,menurow+33,"Levels (1-3)");
item=0;
menuon=2;}
}
break;
case 34:
if (gamestart==2){
if (menuon==0){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(12);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(15);
outtextxy(cx,60,"ame");
menuon=1;
menuflag=0;
menuitem=1;}
if (menuon==1 && menuitem==1 && menuflag==0){
menucol=10;
menurow=63;
menucoll=130;
menuroww=106;
messageboxc=menucol;
messageboxr=menurow;
messageboxcc=menucoll;
messageboxrr=menuroww;
savebox();
dropdownmenu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
outtextxy(menucol+60,menurow+13,"Start");
outtextxy(menucol+60,menurow+33,"Quit");
item=0;
menuflag=1;}
}
break;
case 35:
if (gamestart==2){
if (menuon==0){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=100;
setcolor(12);
outtextxy(cx,60,"H");
cx+=textwidth("H");
cx=cx+1;
setcolor(15);
outtextxy(cx,60,"elp");
menuon=1;
menuflag=0;
menuitem=2;}
if (menuon==1 && menuitem==2 && menuflag==0){
menucol=100;
menurow=63;
menucoll=239;
menuroww=106;
messageboxc=menucol;
messageboxr=menurow;
messageboxcc=menucoll;
messageboxrr=menuroww;
savebox();
dropdownmenu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
outtextxy(menucol+75,menurow+13,"How to use...");
outtextxy(menucol+70,menurow+33,"About");
item=0;
menuflag=1;}
}
break;
case 80:
if (gamestart==2){
if (menuon==2){
if (item==0){
threed_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1);
if (soundon==1){
setcolor(7);
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");
setcolor(15);
outtextxy(menucol+75,menurow+13,"Sound ( ON )");}
if (soundon==0){
setcolor(7);
outtextxy(menucol+75,menurow+13,"Sound ( ON )");
setcolor(15);
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");}
}
if (item==1){
twod_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
if (soundon==1){
outtextxy(menucol+75,menurow+13,"Sound ( ON )");}
if (soundon==0){
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");}
setlinestyle(SOLID_LINE,1,1);
threed_menuitem2();
setcolor(15);
outtextxy(menucol+75,menurow+33,"Levels (1-3)");}
if (item==2){
twod_menuitem2();
setcolor(8);
outtextxy(menucol+75,menurow+33,"Levels (1-3)");}
sound(20);
delay(75);
nosound();
item++;
if (item==3){
item=0;}
}
if (menuon==1 && menuflag==1 && menuitem==1){
if (item==0){
threed_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(15);
outtextxy(menucol+60,menurow+13,"Start");}
if (item==1){
twod_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
outtextxy(menucol+60,menurow+13,"Start");
setlinestyle(SOLID_LINE,1,1);
threed_menuitem2();
setcolor(15);
outtextxy(menucol+60,menurow+33,"Quit");}
if (item==2){
twod_menuitem2();
setcolor(8);
outtextxy(menucol+60,menurow+33,"Quit");}
sound(20);
delay(75);
nosound();
item++;
if (item==3){
item=0;}
}
if (menuon==1 && menuflag==1 && menuitem==2){
if (item==0){
threed_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(15);
outtextxy(menucol+75,menurow+13,"How to use...");}
if (item==1){
twod_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
outtextxy(menucol+75,menurow+13,"How to use...");
setlinestyle(SOLID_LINE,1,1);
threed_menuitem2();
setcolor(15);
outtextxy(menucol+70,menurow+33,"About");}
if (item==2){
twod_menuitem2();
setcolor(8);
outtextxy(menucol+70,menurow+33,"About");}
sound(20);
delay(75);
nosound();
item++;
if (item==3){
item=0;}
}
}
break;
case 13:
if (gamestart==2){
if (menuon==1 && menuitem==1){
restorebox();
if (item==0){
sound(200);
delay(25);
nosound();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");}
if (item==1){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
item=0;
menuon=0;
menuflag=0;
cleardevice();
textcounter=5;
start();
writescore();
gamestart=1;
count=1;
down=1;
ix=1;}
if (item==2){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
quit();
count=1;
ix=0;}
menuon=0;
}
if (menuon==1 && menuitem==2){
restorebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=100;
setcolor(15);
outtextxy(cx,60,"H");
setcolor(12);
cx+=textwidth("H");
cx=cx+1;
outtextxy(cx,60,"elp");
if (item==0){
sound(200);
delay(25);
nosound();}
if (item==1){
howtouse();}
if (item==2){
about();}
menuon=0;}
if (menuon==2){
restorebox();
setcolor(7);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
settextjustify(0,1);
outtextxy(18,11,"0");
if (item==2){
shareware();}
menuon=0;}
}
break;
case 27:
if (gamestart==1){
cleardevice();
textcounter=5;
screen();
menuon=0;
gamestart=2;}
if (gamestart==2){
if (menuon==2){
restorebox();
setcolor(7);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
settextjustify(0,1);
outtextxy(18,11,"0");
menuon=0;}
if (menuon==0){
sound(50);
delay(50);
nosound();}
if (menuon==1 && menuflag==1 && menuitem==1){
restorebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
menuon=0;
menuflag=0;
item=0;
menuitem=1;
}
if (menuon==1 && menuflag==1 && menuitem==2){
restorebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=100;
setcolor(15);
outtextxy(cx,60,"H");
setcolor(12);
cx+=textwidth("H");
cx=cx+1;
outtextxy(cx,60,"elp");
menuon=0;
menuflag=0;
menuitem=1;
item=0;
}
}
break;
case 77:
if (gamestart==1){
setfillstyle(SOLID_FILL,0);
bar(x,y,xx,yy);
if (x<559){
x=x+25;
xx=x+75;}
if (x>559){
x=559;
xx=x+75;}
setfillstyle(SOLID_FILL,9);
bar(x,y,xx,yy);}
break;
case 75:
if (gamestart==1){
setfillstyle(SOLID_FILL,0);
bar(x,y,xx,yy);
if (x>6){
x=x-25;
xx=xx-25;}
if (x<=6){
x=6;
xx=x+75;}
setfillstyle(SOLID_FILL,9);
bar(x,y,xx,yy);}
break;
}
}
cleardevice();
closegraph();
exit(0);}
int screen(){
setfillstyle(SOLID_FILL,8);
bar(0,0,640,21);
setfillstyle(SOLID_FILL,12);
bar(1,1,25,20);
setfillstyle(SOLID_FILL,10);
bar(0,22,640,74);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
settextjustify(0,1);
setcolor(7);
outtextxy(18,11,"0");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(295,12,"GREYcells");
cx=10;
setcolor(15);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
cx=100;
setcolor(15);
outtextxy(cx,60,"H");
cx+=textwidth("H");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"elp");
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
line(0,65,640,65); barx=0; barxx=barx+60; bary=75; baryy=bary+20; bricknum=0; ctr=0;
/* Bricks */
while (baryy<480){
setfillstyle(SOLID_FILL,7);
bar(barx,bary,barxx,baryy);
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
line(barx,bary,barxx,bary);
line(barx,bary,barx,baryy);
if (bricknum==0){
barx=barx+64;
barxx=barx+60;}
if (bricknum==1 && barxx==640){barxx=barxx+30;}
if (bricknum==1 && barxx>=606 && barxx<640){barx=610;barxx=barx+30;}
if (bricknum==1 && barxx>=94 && barxx<606){barx=barx+64;barxx=barx+60;}
if (bricknum==1 && barxx==30){barx=34;barxx=barx+60;}
if (barxx>640){
if (ctr==0 || ctr==2 || ctr==4 || ctr==6 || ctr==8 || ctr==10 || ctr==12 || ctr==14){
bricknum=1;}
if (ctr==1 || ctr==3 || ctr==5 || ctr==7 || ctr==9 || ctr==11 || ctr==13 || ctr==15){
bricknum=0;}
if (bricknum==1){
bary=bary+25;
baryy=bary+20;
barx=0;
barxx=barx+30;}
if (bricknum==0){
bary=bary+25;
baryy=bary+20;
barx=0;
barxx=barx+60;}
ctr++;}
}
if (textcounter==0){
messageboxc=125;
messageboxr=125;
messageboxcc=450;
messageboxrr=200;
midx=265;
sound(100);
delay(75);
nosound();
savebox();
errorscreen();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setusercharsize(1,3,1,1);
settextjustify(0,1);
setcolor(12);
outtextxy(messageboxc+5,messageboxr+5,"Speed");
setcolor(0);
outtextxy(messageboxc+5,messageboxr+35,"Enter ballspeed (less than 100) -");
messageboxc+=textwidth("Enter ballspeed (less than 100) -");
cursorctr=messageboxc+5;
messageboxc=cursorctr;
setfillstyle(SOLID_FILL,15);
bar(messageboxc,messageboxr+45,messageboxc+5,messageboxr+50);}
/* BRICKS */
/* B */
srand( seed ); /* Restart random # function */
count=0;
color=15;
while (!kbhit()){
if (count==0 || count==2){
i=0;
z=50;
q=20;
w=200;
h=125;
ctr=0;
greateri=1000;
bee();}
if (count==0 || count==1){
i=0;
z=150;
q=20;
w=200;
h=125;
ctr=0;
greateri=1000;
arr();}
if (count==0 || count==2){
i=0;
z=250;
q=20;
w=200;
h=125;
greateri=1000;
eye();}
if (count==0 || count==1){
i=0;
z=325;
q=15;
w=200;
h=25;
greateri=100;
ctr=0;
see();}
if (count==0 || count==2){
i=0;
z=425;
q=20;
w=200;
h=125;
greateri=1000;
ctr=0;
kay();}
if (count==0 || count==1){
i=0;
z=595;
q=20;
w=200;
h=15;
greateri=100;
ctr=0;
ess();}
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setcolor(10);
outtextxy(115,340,"A ballgame designed & developed by J.V.Ravichandran");
sound(275);
delay(50);
sound(250);
delay(100);
sound(300);
delay(75);
sound(125);
delay(50);
sound(225);
delay(50);
sound(300);
delay(100);
sound(125);
delay(50);
sound(225);
delay(100);
nosound();
/* End */
delay(200);
count++;
color++;
if (color>=15){
color=0;}
}
while (textcounter!=5){
ctrlbrk(c_break);
key=getch();
switch(key){
case 8:
if (textcounter>0 && messageboxc>cursorctr){
setfillstyle(SOLID_FILL,9);
bar(messageboxc-3,messageboxr+30,messageboxc+10,messageboxr+50);
messageboxc-=textwidth(&key);
textcounter--;}
if (textcounter<=0){textcounter=0;}
if (messageboxc<=cursorctr){messageboxc=cursorctr;}
setfillstyle(SOLID_FILL,15);
bar(messageboxc,messageboxr+45,messageboxc+5,messageboxr+50);
break;
case 27:
sound(200);
delay(50);
nosound();
break;
case 13:
if (textcounter==0){
sound(200);
delay(50);
nosound();}
if (delayover==1 && textcounter>0){
lastcounter=textcounter;
gamestart=2;
count=0;
while (count0){
strcat(&newstr,&str[count]);}
count++;}
delayover=2;}
if (delayover==2){
messageboxc=125;
messageboxr=125;
restorebox();
sprintf(&newstr,"%d",delaytime);
textcounter=5;
ix=1;}
break;
default:
if (delayover==1 && textcounter<4){
setcolor(15);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setusercharsize(1,3,1,1);
settextjustify(0,1);
setcolor(12);
outtextxy(messageboxc+5,messageboxr+35,&key);
setfillstyle(SOLID_FILL,9);
bar(messageboxc,messageboxr+45,messageboxc+5,messageboxr+50);
messageboxc+=textwidth(&key);
setfillstyle(SOLID_FILL,15);
bar(messageboxc,messageboxr+45,messageboxc+5,messageboxr+50);
if (textcounter==0){
strcpy(&str[textcounter],&key);}
if (textcounter>0){
strcpy(&str[textcounter],&key);}
textcounter++;}
break;
}
}
return 1;}
int start(){
x=6;
y=443;
xx=x+75;
yy=y+10;
drawboard();
ctr=0;
barx=0;
bary=0;
barxx=barx+60;
baryy=bary+20;
/* Bricks */
while (ctr<40){
setfillstyle(SOLID_FILL,4);
bar(barx,bary,barxx,baryy);
setlinestyle(SOLID_LINE,1,1);
setcolor(12);
line(barx,bary,barxx,bary);
line(barx,bary,barx,baryy);
barx=barx+64;
barxx=barx+60;
ctr++;
if (ctr==11 || ctr==21 || ctr==31){
bary=bary+24;
baryy=bary+20;
barx=0;
barxx=barx+60;}
}
setfillstyle(SOLID_FILL,4);
bar(barx,bary,barxx,baryy);
setlinestyle(SOLID_LINE,1,1);
setcolor(12);
line(barx,bary,barxx,bary);
line(barx,bary,barx,baryy);
/* Frame */ setfillstyle(SOLID_FILL,2); bar(0,100,5,460); bar(0,455,640,460); bar(635,100,640,460);
ballrow=125;
ballcol=300;
once=0;
down=1;
brickctr=1;
while (brickctr<=40){
strcpy(&brick[brickctr],"0");
brickctr++;}
incolor=12;
ball();
if (delayover!=3 && delayover!=5){
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(12);
outtextxy(200,250,"Have a ball !");
scorex=510;
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(14);
outtextxy(scorex,470,"Score -");
scorex+=textwidth("Score -");
scorex=scorex+5;
score=0;
scorectr=0;
sprintf(&newstr,"%d",score);
setcolor(15);
outtextxy(scorex,470,&newstr);
setcolor(12);
outtextxy(275,470,"Level - 1");
ballnum=0;
ballcx=10;
while (ballnum<5){
setcolor(15);
circle(ballcx,470,7);
ballcx=ballcx+25;
ballnum++;}
ballcx=10;
ballnum=0;
scorex=510;
scorex+=textwidth("Score -");
scorex=scorex+5;
delay(50);
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(0);
outtextxy(200,250,"Have a ball !");}
if (delayover==3 || delayover==5){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(12);
outtextxy(275,470,"Level - 1");
if (ballnum==0){
ballcx=10;}
if (ballnum==1){
ballcx=35;}
if (ballnum==2){
ballcx=60;}
if (ballnum==3){
ballcx=85;}
if (ballnum==4){
ballcx=110;}
if (ballnum>4){
ballcx=10;
ballnum=0;}
lastballnum=ballnum;
lastballcx=ballcx;
while (ballnum<5){
setcolor(15);
circle(ballcx,470,7);
ballcx=ballcx+25;
ballnum++;}
ballnum=lastballnum;
ballcx=lastballcx;
scorex=510;
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(14);
outtextxy(scorex,470,"Score -");
scorex+=textwidth("Score -");
scorex=scorex+5;}
gamestart=1;
wallctr=0;
evaluateflag=0;
return 1;}
int drawboard(){
setfillstyle(SOLID_FILL,9);
bar(x,y,xx,yy);
return 1;}
int ball(){
setcolor(incolor);
setfillstyle(SOLID_FILL,incolor);
circle(ballcol,ballrow,7);
floodfill(ballcol,ballrow,incolor);
return 1;}
int bee(){
while (ctr<17){
delay(100);
for( i=0 ; i
srand( seed ); /* Restart Random # at same # */
return 1;}
int arr(){
while (ctr<16){
delay(100);
for( i=0 ; i
vx=z+random(q-1); /* Column */
vy=w+random(h-1); /* Row */
putpixel( vx, vy, color );}
ctr++;
if (ctr==1){
i=0;
z=170;
q=15;
w=200;
greateri=50;
h=15;}
if (ctr==2){
i=0;
greateri=50;
z=180;
q=15;
w=200;
h=25;}
if (ctr==3){
i=0;
greateri=50;
z=190;
q=15;
w=210;
h=25;}
if (ctr==4){
i=0;
greateri=50;
z=200;
q=15;
w=220;
h=25;}
if (ctr==5){
i=0;
greateri=50;
z=190;
q=15;
w=210;
h=25;}
if (ctr==6){
i=0;
greateri=50;
z=170;
q=15;
w=250;
h=25;}
if (ctr==7){
i=0;
greateri=50;
z=180;
q=15;
w=240;
h=25;}
if (ctr==8){
i=0;
z=190;
q=15;
w=230;
greateri=50;
h=25;}
if (ctr==9){
i=0;
z=170;
q=15;
w=250;
greateri=50;
h=15;}
if (ctr==10){
i=0;
greateri=50;
z=180;
q=15;
w=250;
h=25;}
if (ctr==11){
i=0;
greateri=50;
z=180;
q=15;
w=260;
h=25;}
if (ctr==12){
i=0;
greateri=50;
z=195;
q=15;
w=270;
h=25;}
if (ctr==13){
i=0;
greateri=50;
z=200;
q=15;
w=280;
h=25;}
if (ctr==14){
i=0;
greateri=50;
z=205;
q=15;
w=290;
h=25;}
if (ctr==15){
i=0;
greateri=50;
z=205;
q=15;
w=300;
h=25;}
}
srand(seed);
return 1;}
int eye(){
for( i=0 ; i
delay(100);
for( i=0 ; i
q=15;
w=300;
greateri=100;
h=25;}
if (ctr==18){
i=0;
z=360;
q=15;
w=300;
greateri=100;
h=25;}
if (ctr==19){
i=0;
z=370;
q=15;
w=300;
greateri=100;
h=25;}
if (ctr==20){
i=0;
z=360;
q=15;
w=200;
greateri=100;
h=25;}
srand(seed);
}
return 1;}
int kay(){
while (ctr<10){
delay(100);
for( i=0 ; i
w=195;
greateri=100;
h=25;}
if (ctr==3){
i=0;
z=565;
q=15;
w=205;
greateri=100;
h=25;}
if (ctr==4){
i=0;
z=555;
q=15;
w=210;
greateri=100;
h=25;}
if (ctr==5){
i=0;
z=545;
q=15;
w=215;
greateri=100;
h=25;}
if (ctr==6){
i=0;
z=545;
q=15;
w=225;
greateri=100;
h=25;}
if (ctr==7){
i=0;
z=555;
q=15;
w=235;
greateri=100;
h=25;}
if (ctr==8){
i=0;
z=565;
q=15;
w=245;
greateri=100;
h=25;}
if (ctr==9){
i=0;
z=575;
q=15;
w=255;
greateri=100;
h=25;}
if (ctr==10){
i=0;
z=585;
q=15;
w=265;
greateri=100;
h=25;}
if (ctr==11){
i=0;
z=585;
q=15;
w=275;
greateri=100;
h=25;}
if (ctr==12){
i=0;
z=575;
q=15;
w=285;
greateri=100;
h=25;}
if (ctr==13){
i=0;
z=565;
q=15;
w=290;
greateri=100;
h=25;}
if (ctr==14){
i=0;
z=555;
q=15;
w=290;
greateri=100;
h=25;}
if (ctr==15){
i=0;
z=545;
q=15;
w=295;
greateri=100;
h=25;}
if (ctr==16){
i=0;
z=535;
q=15;
w=300;
greateri=100;
h=25;}
if (ctr==17){
i=0;
z=525;
q=15;
w=300;
greateri=100;
h=25;}
srand(seed);
}
return 1;}
int dropdownmenu(){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setfillstyle(SOLID_FILL,15);
bar(menucol,menurow+2,menucoll,menuroww);
setfillstyle(SOLID_FILL,0);
bar(menucol+1,menurow+3,menucoll-1,menuroww-1);
setfillstyle(SOLID_FILL,7);
bar(menucol+4,menurow+5,menucoll-3,menurow+20);
bar(menucol+4,menurow+25,menucoll-3,menurow+41);
setlinestyle(SOLID_LINE,1,2);
setcolor(15);
line(menucol+4,menurow+5,menucoll-3,menurow+5);
line(menucol+4,menurow+5,menucol+4,menurow+20);
line(menucol+4,menurow+25,menucoll-3,menurow+25);
line(menucol+4,menurow+25,menucol+4,menurow+41);
setcolor(0);
line(menucol+4,menurow+20,menucoll-3,menurow+20);
line(menucoll-3,menurow+5,menucoll-3,menurow+20);
line(menucol+4,menurow+41,menucoll-3,menurow+41);
line(menucoll-3,menurow+25,menucoll-3,menurow+41);
/* line in between menu items */
setcolor(15);
line(menucol,menurow+22,menucoll,menurow+22);
return 1;}
int threed_menu(){
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
line(menucoll-6,menurow+8,menucoll-6,menurow+17);
line(menucol+7,menurow+17,menucoll-6,menurow+17);
setcolor(0);
line(menucol+7,menurow+7,menucoll-7,menurow+7);
line(menucol+7,menurow+7,menucol+7,menurow+17);
return 1;}
More code