rem DBC Challenge rem Ballancing Challenge rem by TheComet rem setup screen set display mode 1024,768,32 randomize timer() sync on sync rate 60 backdrop on color backdrop 0 hide mouse rem dimensions dim beer(7) rem generate everything gosub _create_images gosub _create_objects rem menu menu: gosub _menu rem main loop dx=-59 level=0 tx1=(screen width()/4)-(screen width()/8) tx2=(screen width()/4)+(screen width()/8) tx3=(screen width()/4)+((screen width()/8)*3) tx4=(screen width()/4)+((screen width()/8)*5) time=0 loser=0 level=0 do rem time oldtime=time/1000 inc time if time<80 then for t=1000 to 1003:rotate object t,0,0,0:next t if time/1000<>oldtime then inc level rem alarm ink rgb(0,0,255),0 line 0,40,screen width(),40 line screen width()/4,0,screen width()/4,40 line screen width()/2,0,screen width()/2,40 line screen width()/4*3,0,screen width()/4*3,40 if object angle z(1000)>1 and object angle z(1000)<180 or object angle z(1000)<359 and object angle z(1000)>180 then ink rgb(255,0,0),0:center text tx1,10,"Alarm!" else ink rgb(0,255,0),0:center text tx1,10,"OK" if object angle z(1001)>1 and object angle z(1001)<180 or object angle z(1001)<359 and object angle z(1001)>180 then ink rgb(255,0,0),0:center text tx2,10,"Alarm!" else ink rgb(0,255,0),0:center text tx2,10,"OK" if object angle z(1002)>1 and object angle z(1002)<180 or object angle z(1002)<359 and object angle z(1002)>180 then ink rgb(255,0,0),0:center text tx3,10,"Alarm!" else ink rgb(0,255,0),0:center text tx3,10,"OK" if object angle z(1003)>1 and object angle z(1003)<180 or object angle z(1003)<359 and object angle z(1003)>180 then ink rgb(255,0,0),0:center text tx4,10,"Alarm!" else ink rgb(0,255,0),0:center text tx4,10,"OK" text 20,50,"Level : "+str$(level)+"/10" rem move if leftkey()=1 and pushed=0 if dx=-19 then dx=-59 if dx=19 then dx=-19 if dx=59 then dx=19 pushed=1 endif if rightkey()=1 and pushed=0 if dx=19 then dx=59 if dx=-19 then dx=19 if dx=-59 then dx=-19 pushed=1 endif if rightkey()=0 and leftkey()=0 then pushed=0 rem control camera cx#=curvevalue(dx,cx#,20) position camera cx#,5,-30 rem tip boards back and forth for t=1000 to 1003 comon=(10-level)*100 if object angle z(t)<1 or object angle z(t)>359 and rnd(comon)=5:if rnd(1)=0:zrotate object t,358:else:zrotate object t,2:endif:endif if object angle z(t)>1 and object angle z(t)<80 then zrotate object t,wrapvalue(object angle z(t)+0.1) if object angle z(t)<359 and object angle z(t)>280 then zrotate object t,wrapvalue(object angle z(t)-0.1) rem position beers position object beer((t-1000)*2),limb position x(t,1),limb position y(t,1),-9:zrotate object beer((t-1000)*2),object angle z(t) position object beer(((t-1000)*2)+1),limb position x(t,2),limb position y(t,2),-9:zrotate object beer(((t-1000)*2)+1),object angle z(t) rem lose if object angle z(t)>79 and object angle z(t)<180 then loser=1 if object angle z(t)<281 and object angle z(t)>180 then loser=1 next t rem rotate them back correctly if keystate(30)=1 if dx=-59 then zrotate object 1000,wrapvalue(object angle z(1000)+0.4) if dx=-19 then zrotate object 1001,wrapvalue(object angle z(1001)+0.4) if dx=19 then zrotate object 1002,wrapvalue(object angle z(1002)+0.4) if dx=59 then zrotate object 1003,wrapvalue(object angle z(1003)+0.4) endif if keystate(32)=1 if dx=-59 then zrotate object 1000,wrapvalue(object angle z(1000)-0.4) if dx=-19 then zrotate object 1001,wrapvalue(object angle z(1001)-0.4) if dx=19 then zrotate object 1002,wrapvalue(object angle z(1002)-0.4) if dx=59 then zrotate object 1003,wrapvalue(object angle z(1003)-0.4) endif rem lose if loser=1 for x=1 to 180 rem beer falls to ground for t=1000 to 1003 if object angle z(t)>79 and object angle z(t)<180 or object angle z(t)<281 and object angle z(t)>180 if object position y(beer((t-1000)*2))>-4.5 then position object beer((t-1000)*2),object position x(beer((t-1000)*2)),object position y(beer((t-1000)*2))-0.1,-9 if object position y(beer(((t-1000)*2)+1))>-4.5 then position object beer(((t-1000)*2)+1),object position x(beer(((t-1000)*2)+1)),object position y(beer(((t-1000)*2)+1))-0.1,-9 zrotate object beer((t-1000)*2),curveangle(90,object angle z(beer((t-1000)*2)),30) zrotate object beer(((t-1000)*2)+1),curveangle(90,object angle z(beer(((t-1000)*2)+1)),30) rem position camera set camera to follow object position x(t),0,0,0,50,5,60,0 endif next t sync next x time1=0 repeat set camera to follow 0,0,0,0,120,20,20,0 inc time1 center text screen width()/2,50,"LOOSER! Press any key to return to menu" center text screen width()/2,70,"Your Score : "+str$(time) sync until scancode()>0 and time1>100 goto menu endif rem refresh screen sync rem end of main loop loop _menu: rem make beers according to score beers=time/1000 o=5000 for x=1 to beers limb=0 inc o make object plain o,0,0 inc o restore beer read obj for t=1 to obj read x1 read y1 read z1 read x2 read y2 read z2 read x3 read y3 read z3 read r read g read b inc limb make object triangle o,x1,y1,z1,x2,y2,z2,x3,y3,z3 make mesh from object 1,o delete object o add limb o-1,limb,1 delete mesh 1 color limb o-1,limb,rgb(r,g,b) next t scale object o-1,5,5,5 position object o-1,-28+((x-1)*4),-20,40 lock object on o-1 next x show mouse set text size 15 do rem control camera inc s s#=sin(s)*45 set camera to follow 0,0,0,wrapvalue(s#),120,10,40,0 rem sprite logo sprite 1,screen width()/2-320,40,1 rem control menu ink rgb(255,255,255),0 text screen width()/2-320,280,"Controls : Use Left and Right Arrow Keys to Switch between boards." text screen width()/2-320,300,"Use <a> and <d> to re-balance the boards. Don`t let the beer fall off!" text screen width()/2-320,320,"How many beers can you earn?Have Fun! TheComet" center text screen width()/2,350,"Play" center text screen width()/2,370,"Exit" if mousey()>340 and mousey()<360 then ink rgb(0,255,0),0:center text screen width()/2,350,"Play":if mouseclick()=1 then exit if mousey()>360 and mousey()<380 then ink rgb(0,255,0),0:center text screen width()/2,370,"Exit":if mouseclick()=1 then end rem last score text 20,screen height()-200,"Your Last Score : "+str$(time) text 20,screen height()-180,"You Have Earned "+str$(beers)+" Beers!" for t=1 to beers obj=5000+((t*2)-1) yrotate object obj,wrapvalue(object angle y(obj)+2) next t sync loop rotate camera 0,0,0 hide mouse delete sprite 1 rem delete beers for t=1 to beers obj=5000+((t*2)-1) delete object obj next t return _create_images: rem balancing logo create bitmap 1,640,100 ink 0,0 box 0,0,319,99 ink rgb(255,120,10),0 set text size 60 set text font "arial" center text 320,10,"Beer Balancing" get image 1,0,0,640,100 delete bitmap 1 return _create_objects: rem make level o=0 restore level read obj for t=1 to obj read x1 read y1 read z1 read x2 read y2 read z2 read x3 read y3 read z3 read r read g read b inc o make object triangle o,x1,y1,z1,x2,y2,z2,x3,y3,z3 color object o,rgb(r,g,b) next t rem make 8 beers for x=0 to 7 limb=0 inc o make object plain o,0,0 beer(x)=o inc o restore beer read obj for t=1 to obj read x1 read y1 read z1 read x2 read y2 read z2 read x3 read y3 read z3 read r read g read b inc limb make object triangle o,x1,y1,z1,x2,y2,z2,x3,y3,z3 make mesh from object 1,o delete object o add limb o-1,limb,1 delete mesh 1 color limb o-1,limb,rgb(r,g,b) next t scale object o-1,5,5,5 next x rem create 4 boards for t=1000 to 1003 make object box t,12,1,2 color object t,rgb(40,0,0) next t rem make two dummy objects at each end of board for t=1000 to 1003 make object plain 1004,0,0 make mesh from object 1,1004 delete object 1004 make object plain 1004,0,0 make mesh from object 2,1004 delete object 1004 add limb t,1,1 add limb t,2,2 offset limb t,1,-5,0.5,0 offset limb t,2,5,0.5,0 delete mesh 1 delete mesh 2 next t rem position boards position object 1000,-59,7,-9 position object 1001,-19,7,-9 position object 1002,19,7,-9 position object 1003,59,7,-9 return rem Data Statements ------------------------------ level: data 68,-60,-5,5,-60,-5,-5,-60,5,-5,50,0,0,-60,-5,5,-60,5,5,-60,5,-5,50,0,0,-60,5,5,-60,5,-5 data 60,5,-5,80,0,0,-60,5,5,60,5,-5,60,5,5,80,0,0,-60,-5,-5,-60,5,-5,60,5,-5,100,0,0,-60,-5 data -5,60,-5,-5,60,5,-5,100,0,0,60,-5,5,60,-5,-5,60,5,-5,110,0,0,60,-5,5,60,5,5,60,5,-5,110 data 0,0,-60,5,-5,-60,3,-5,-60,3,-10,120,0,0,-60,5,-5,-60,5,-10,-60,3,-10,120,0,0,-60,3,-5,-60 data 3,-10,-58,3,-10,120,0,0,-60,3,-5,-58,3,-5,-58,3,-10,120,0,0,-58,3,-5,-58,5,-5,-58,5,-10 data 160,0,0,-58,3,-5,-58,3,-10,-58,5,-10,160,0,0,-60,5,-10,-60,3,-10,-58,3,-10,150,0,0,-60,5 data -10,-58,5,-10,-58,3,-10,150,0,0,-60,5,-5,-60,5,-10,-59,7,-10,130,0,0,-60,5,-5,-59,7,-5 data -59,7,-10,130,0,0,-58,5,-5,-58,5,-10,-59,7,-10,160,0,0,-58,5,-5,-59,7,-5,-59,7,-10,160,0 data 0,-60,5,-10,-59,7,-10,-58,5,-10,170,0,0,-20,5,-5,-20,3,-5,-20,3,-10,120,0,0,-20,5,-5,-20 data 5,-10,-20,3,-10,120,0,0,-20,3,-5,-20,3,-10,-18,3,-10,120,0,0,-20,3,-5,-18,3,-5,-18,3,-10 data 120,0,0,-18,3,-5,-18,5,-5,-18,5,-10,160,0,0,-18,3,-5,-18,3,-10,-18,5,-10,160,0,0,-20,5,-10 data -20,3,-10,-18,3,-10,150,0,0,-20,5,-10,-18,5,-10,-18,3,-10,150,0,0,-20,5,-5,-20,5,-10,-19,7 data -10,130,0,0,-20,5,-5,-19,7,-5,-19,7,-10,130,0,0,-18,5,-5,-18,5,-10,-19,7,-10,160,0,0,-18,5 data -5,-19,7,-5,-19,7,-10,160,0,0,-20,5,-10,-19,7,-10,-18,5,-10,170,0,0,20,5,-5,20,3,-5,20,3 data -10,120,0,0,20,5,-5,20,5,-10,20,3,-10,120,0,0,20,3,-5,20,3,-10,18,3,-10,120,0,0,20,3,-5,18 data 3,-5,18,3,-10,120,0,0,18,3,-5,18,5,-5,18,5,-10,160,0,0,18,3,-5,18,3,-10,18,5,-10,160,0,0 data 20,5,-10,20,3,-10,18,3,-10,150,0,0,20,5,-10,18,5,-10,18,3,-10,150,0,0,20,5,-5,20,5,-10,19 data 7,-10,130,0,0,20,5,-5,19,7,-5,19,7,-10,130,0,0,18,5,-5,18,5,-10,19,7,-10,160,0,0,18,5 data -5,19,7,-5,19,7,-10,160,0,0,20,5,-10,19,7,-10,18,5,-10,170,0,0,60,5,-5,60,3,-5,60,3 data -10,120,0,0,60,5,-5,60,5,-10,60,3,-10,120,0,0,60,3,-5,60,3,-10,58,3,-10,120,0,0,60 data 3,-5,58,3,-5,58,3,-10,120,0,0,58,3,-5,58,5,-5,58,5,-10,160,0,0,58,3,-5,58,3,-10,58 data 5,-10,160,0,0,60,5,-10,60,3,-10,58,3,-10,150,0,0,60,5,-10,58,5,-10,58,3,-10,150,0,0 data 60,5,-5,60,5,-10,59,7,-10,130,0,0,60,5,-5,59,7,-5,59,7,-10,130,0,0,58,5,-5,58,5 data -10,59,7,-10,160,0,0,58,5,-5,59,7,-5,59,7,-10,160,0,0,60,5,-10,59,7,-10,58,5,-10 data 170,0,0,-200,-5,-200,200,-5,-200,200,-5,200,0,0,50,-200,-5,-200,-200,-5,200,200,-5,200 data 0,0,50,-200,-5,-200,-200,-5,200,-200,200,200,0,0,70,-200,-5,-200,-200,200,-200,-200 data 200,200,0,0,70,200,-5,-200,200,-5,200,200,200,200,0,0,70,200,-5,-200,200,200,-200,200 data 200,200,0,0,70,-200,-5,200,200,-5,200,200,200,200,0,0,30,-200,-5,200,-200,200,200,200,200,200,0,0,30 beer: data 36,-20,0,0,0,0,20,0,10,0,200,200,200,0,0,20,20,0,0,0,10,0,190,190,190,20,0,0,0,0,-20 data 0,10,0,200,200,200,0,0,-20,-20,0,0,0,10,0,210,210,210,-2,0,-2,2,0,-2,2,20,-2,190,190 data 190,-2,0,-2,-2,20,-2,2,20,-2,190,190,190,-2,0,-2,-2,0,2,-2,20,2,200,200,200,-2,0,-2 data -2,20,-2,-2,20,2,200,200,200,-2,0,2,2,0,2,2,20,2,210,210,210,-2,0,2,-2,20,2,2,20,2 data 210,210,210,2,0,-2,2,0,2,2,20,2,200,200,200,2,0,-2,2,20,-2,2,20,2,200,200,200,-2,20 data -2,2,20,-2,8,40,-8,239,139,3,-2,20,-2,-8,40,-8,8,40,-8,239,139,3,-2,20,-2,-2,20,2,-8 data 40,8,249,149,3,-2,20,-2,-8,40,-8,-8,40,8,249,149,3,-2,20,2,2,20,2,8,40,8,239,139,3 data -2,20,2,-8,40,8,8,40,8,239,139,3,2,20,-2,2,20,2,8,40,8,229,129,3,2,20,-2,8,40,-8,8 data 40,8,229,129,3,-8,40,-8,8,40,-8,10,60,-10,239,139,3,-8,40,-8,-10,60,-10,10,60,-10,239,139,3,-8 data 40,-8,-8,40,8,-10,60,10,249,149,3,-8,40,-8,-10,60,-10,-10,60,10,249,149,3,-8,40,8,8,40,8,10,60,10 data 239,139,3,-8,40,8,-10,60,10,10,60,10,239,139,3,8,40,-8,8,40,8,10,60,10,229,129,3,8,40,-8 data 10,60,-10,10,60,10,229,129,3,-10,60,-10,10,60,-10,9,70,-9,190,190,190,-10,60,-10,-9,70,-9,9,70,-9,190,190 data 190,-10,60,-10,-10,60,10,-9,70,9,200,200,200,-10,60,-10,-9,70,-9,-9,70,9,200,200,200,-10,60,10,10 data 60,10,9,70,9,210,210,210,-10,60,10,-9,70,9,9,70,9,210,210,210,10,60,-10,10,60,10,9,70,9,200,200 data 200,10,60,-10,9,70,-9,9,70,9,200,200,200