!! Quaddle Smatch Boom, Delay, FixAng, GridBounce, GridMatch, GridRace, GridSmash, GridSquash, HandleEgg HideStuff, LoadData, Menu, Missed, MoveBall, MoveJuggleBalls, MoveSquashBugs, NewEgg, NewJuggleBall NewSquashBug, OnBackKey, PaddleMove, PaddleBounce, PaddleMatch, PaddleRace, PaddleSmash PaddleSquash, PrepJuggleBalls, PrepRaceGrid, PrepSmatchGrid, PrepSquashGrid, ReadyPaddles Score, SetScreen, SetGlobalVars, SetMatchVars, SetSmashVars, SetSquashVars, SetRaceVars SetJuggleVars, ShowStats, UnloadData, functions DeleteBitmaps[o[]count), LoadBitmaps(optr[], file$, count) MenuSelect(s$), Slider(title$,min,max,current,r) Gettextline$ !! debug=0 File.Root tmp$ isAPK=!Is_In("rfo-basic",tmp$) gdir$="Quaddle/" sdir$="Quaddle/" pf$="#,###,###" % format string for scores bundle.create globals bundle.put 1,"changed",0 array.load game$[],"Match","Smash","Juggle","Race","Squash" gosub functions dim grid[13,13] skill=1 gosub SetScreen tDelay=1000/30 gosub CustomLoadVars % load paddle speed and spin angle gosub MakeBackColors search$="Welcome" gosub NextBackColor gosub HelpShowText show_menu=1 while 1 if show_menu then gosub Menu if skill=4 game$=game$[game]+" ??" gosub CustomLoadVars else game$=game$[game]+" L"+int$(skill) endif gr.modify stat1, "text",game$ tstart=time() gosub game, PlayMatch, PlaySmash, PlayJuggle, PlayRace, PlaySquash gosub Boom show_menu=menuselect("Try Again,Return to Menu") if show_menu=1 then show_menu=0 gosub NextBackColor repeat !====== PlayJuggle: gosub SetJuggleVars gosub SetGlobalVars gr.modify stat4, "text", "Balls "+int$(bCount) gosub PrepJuggleBalls gosub ReadyPaddles gosub GetBackColor gr.hide oBall while bCount>0 if egg_timer++>peace egg_timer=0 gosub NewJuggleBall endif gosub MoveJuggleBalls gosub PaddleMove gosub DrawStuff gr.render gosub Delay repeat return !===== PlayMatch: gosub SetMatchVars gosub SetGlobalVars gr.modify stat4, "text", "Balls "+int$(misses) gosub PrepSmatchGrid gosub ReadyPaddles gosub GetBackColor while misses>0 if bpause--<1 then gosub MoveBall if blockcount<2 hits=hitbonus+1 points+=1000 gosub Score gosub PrepSmatchGrid endif gosub PaddleMove gosub PaddleBounce if hit then gosub PaddleMatch gosub GridMatch gosub HandleEgg gosub DrawStuff gr.render gosub Delay repeat return !===== PlayRace: gosub SetRaceVars gosub SetGlobalVars gr.modify stat4, "text", "Balls "+int$(misses) gosub PrepRaceGrid gosub ReadyPaddles gosub GetBackColor while misses>0 if bpause--<1 then gosub MoveBall if egg_timer++>peace then egg_timer=0 : bs+=acc gosub PaddleMove gosub PaddleBounce if hit then gosub PaddleRace if miss then bs*=0.6 gosub GridRace gosub DrawStuff gr.render gosub Delay repeat return !===== PlaySmash: gosub SetSmashVars gosub SetGlobalVars gr.modify stat4, "text", "Balls "+int$(misses) gosub PrepSmatchGrid gosub ReadyPaddles gosub GetBackColor while misses>0 if bpause--<1 then gosub MoveBall gosub PaddleMove gosub PaddleBounce if hit then gosub PaddleSmash gosub GridSmash gosub HandleEgg gosub DrawStuff gr.render gosub Delay repeat return !===== PlaySquash: gosub SetSquashVars gosub SetGlobalVars gr.modify stat4, "text", "Lives "+int$(misses) gosub PrepSquashGrid gosub ReadyPaddles gosub GetBackColor while misses>0 if egg_timer++>peace egg_timer=0 gosub NewSquashBug endif if bpause--<1 then gosub MoveBall gosub PaddleMove gosub PaddleSquash gosub MoveSquashBugs gosub GridSquash gosub DrawStuff gr.render gosub Delay repeat return !===== AddScore: w$=using$(,"game='%s' AND skill='%s'",int$(game),int$(skill)) sql.query cursor, sdb, "scores", "points,game,skill", w$, "points DESC" for i=1 to 12 sql.next d,cursor, t$ if d then lowest=1 : f_n.break t$=trim$(replace$(t$,",","")) if is_number(t$) then lowest=val(t$) next i w$=using$(,"game='%.0f' AND skill='%.0f' AND points<'%s'",game,skill,format$(pf$,lowest)) sql.delete sdb,"scores",w$ lowest=max(lowest,1) if points0.5 then soundpool.play n, sbounce_paddle else soundpool.play n, sbounce_grid gr.render pause 50 next i gosub AddScore return !===== CustomLoadVars: bundle.put 1, "changed",0 w$=using$(,"game='%.0f'",game) sql.query cursor, sdb, "custom", "vars", w$, "_id ASC" sql.query.length l, cursor dim customvars[l] for i=1 to l sql.next d, cursor, t$ customvars[i]=val(t$) next i if game=0 !options= paddle_speed, spin_angle paddle_speed=customvars[1] spin_angle=customvars[2] else acc=customvars[1] bCount=customvars[2] blockcount=customvars[3] bs=customvars[4] bugspeed=customvars[5] hitbonus=customvars[6] hives=customvars[7] js=customvars[8] misses=customvars[9] peace=customvars[10] pLength=customvars[11] gw=customvars[12] gd=customvars[13] endif return !===== CustomResetVars: paddle_speed=0: spin_angle=0 gosub SetGlobalVars game=0 gosub CustomSaveVars skill=2 game=1 gosub SetMatchVars gosub CustomSaveVars game=2 gosub SetSmashVars gosub CustomSaveVars game=3 gosub SetJuggleVars gosub CustomSaveVars game=4 gosub SetRaceVars gosub CustomSaveVars game=5 gosub SetSquashVars gosub CustomSaveVars return !===== CustomSaveVars: !popup "custom vars saved\nhiscores cleared" w$=using$(,"game='%.0f' AND skill='4'",game) sql.delete sdb, "scores", w$ w$=using$(,"game='%.0f' ",game) sql.delete sdb, "custom", w$ if game=0 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(paddle_speed) Sql.insert sdb, "custom", "game",int$(game), "vars", str$(spin_angle) else Sql.insert sdb, "custom", "game",int$(game), "vars", str$(acc) %1 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(bCount) %2 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(blockcount) %3 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(bs) %4 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(bugspeed) %5 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(hitbonus) %6 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(hives) %7 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(js) %8 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(misses) %9 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(peace) %10 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(pLength) %11 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(gw) %12 Sql.insert sdb, "custom", "game",int$(game), "vars", str$(gd) %13 endif return !====== Delay: if paused then gosub pause gosub ShowStats do pause 2 until time()>tLast+tDelay tLast=time() return !===== DrawStuff: gr.modify oBall, "x", bx+offset, "y",by lx+=offset gr.modify oPaddleL, "left",offset, "right",offset+pWidth, "top",ly-pLength, "bottom",ly+pLength gr.modify oPaddleR, "left",offset+DISPLAY_W-pWidth, "right",offset+DISPLAY_W, "top",ly-pLength, "bottom",ly+pLength gr.modify oPaddleT, "left",lx-pLength, "right",lx+pLength, "top",0, "bottom",pWidth gr.modify oPaddleB, "left",lx-pLength, "right",lx+pLength, "top",DISPLAY_H-pWidth, "bottom",DISPLAY_H lx-=offset return !====== FixAng: if ang>a360 then ang-=a360 if angogx & gy<>ogy !handle overlap !! ang+=180 gosub FixAng !! if debug then gr.modify stat1,"text", "overlap" : pause 1500 bx=obx: by=oby for i=1 to bs bx+=sx: by+=sy if floor(sx/ss)<>ogx ang=a360-ang gosub FixAng f_n.break elseif floor(sy/ss)<>ogy ang=a180-ang gosub FixAng f_n.break endif next i elseif gx<>ogx ang=a360-ang gosub FixAng else ang=a180-ang gosub FixAng endif return !===== GridMatch: ogx=gx ogy=gy gx=1+floor(bx/ss) gy=1+floor(by/ss) !if gx<1 | gx>11 |gy<1 |gy>11 then return g=grid[gx,gy] if g<1 if ogx<>gx & ogy<>gy if grid[gx,ogy]>0 & grid[ogx,gy]>0 if debug then gr.modify stat1,"text", "diag pass" : pause 1500 ang+=180 bx=obx by=oby gosub FixAng endif endif elseif hits>hitbonus gosub Score grid[gx,gy]=0 blockcount-- gr.rect n, (gx-1)*ss,(gy-1)*ss,gx*ss,gy*ss hits+=1 soundpool.play n, sblock_smashed b=0 elseif g=b | b=0 if b=0 b=g gr.modify oBall, "paint", colors[g] endif gosub Score grid[gx,gy]=0 blockcount-- gr.rect n, (gx-1)*ss,(gy-1)*ss,gx*ss,gy*ss if ++hits>hitbonus soundpool.play n, ssuperball gr.modify oBall, "paint", colors[5] oang=-1 b=0 else soundpool.play n, sblock_smashed endif else soundpool.play n, sbounce_grid b=g gr.modify oBall, "paint", colors[b] hits-=0.25 gosub GridBounce endif return !===== GridRace: ogx=gx ogy=gy gx=1+floor(bx/ss) gy=1+floor(by/ss) !if gx<1 | gx>12 |gy<1 |gy>12 then return g=grid[gx,gy] if g<1 if ogx<>gx & ogy<>gy if grid[gx,ogy]>0 & grid[ogx,gy]>0 if debug then gr.modify stat1,"text", "diag pass" : pause 1500 ang+=180 bx=obx by=oby gosub FixAng endif endif elseif g=1 soundpool.play n, sbounce_grid if gx<>ogx & gy<>ogy ang+=180 elseif gx<>ogx ang=(a360-toradians(-45+rnd()*90))-ang else ang=(a180-toradians(-45+rnd()*90))-ang endif gosub FixAng hits=0 elseif g=2 soundpool.play n, sbounce_grid gosub GridBounce bs+=acc*2 hits=0 elseif g=3 soundpool.play n, ssuperball gosub GridBounce points+=hits*50 gosub Score hits=0 elseif g=4 soundpool.play n, sblock_smashed bs-=acc*2 gosub Score grid[gx,gy]=0 gr.rect n, (gx-1)*ss,(gy-1)*ss,gx*ss,gy*ss do gx=3+floor(rnd()*9) gy=3+floor(rnd()*9) until grid[gx,gy]=0 grid[gx,gy]=4 gr.bitmap.draw n, bblocks[4], (gx-1)*ss, (gy-1)*ss endif return !===== GridSmash: ogx=gx ogy=gy gx=1+floor(bx/ss) gy=1+floor(by/ss) !if gx<1 | gx>12 |gy<1 |gy>12 then return g=grid[gx,gy] if g<1 if ogx<>gx & ogy<>gy if grid[gx,ogy]>0 & grid[ogx,gy]>0 if debug then gr.modify stat1,"text", "diag pass" : pause 1500 ang+=180 bx=obx by=oby gosub FixAng endif endif elseif hits>hitbonus |b=1 if hits=0 then gosub Score if air=1 then hits++ else hits=1 air=1 if blockcount<2 air=1 points+=1000 gosub Score hits=hitbonus*2 gosub PrepSmatchGrid endif else soundpool.play n, sbounce_grid hits+=g-1 gosub Score gr.bitmap.draw n, bblocks[g-1], (gx-1)*ss,(gy-1)*ss air=1 endif if hits12 |gy<1 |gy>12 then return g=grid[gx,gy] if g<1 else gosub GridBounce egg_timer=0 soundpool.play n, sbounce_grid gosub Score !hits++ bx=obx: by=oby endif return !===== HandleEgg: if egg_timer++>peace then gosub NewEgg if egg=0 then return eggx+=eggdx eggy+=eggdy gr.modify oEgg, "x",eggx+offset, "y",eggy if GR_COLLISION(oEgg, oBall) soundpool.play n, ssuperball misses++ egg=0 gr.modify stat4, "text", "Balls "+int$(misses) gr.hide oEgg endif i=1+floor((eggx+eggdx)/ss) j=1+floor((eggy+eggdy)/ss) if eggx<0|eggx>DISPLAY_W | eggy<0|eggy>DISPLAY_H egg=0 gr.hide oEgg soundpool.play n, segg_hatch elseif i>0 & i<12 & j>0 & j<12 g=grid[i,j] if g>0 egg=0 gr.hide oEgg i=1+floor(eggx/ss) j=1+floor(eggy/ss) g=1+floor(rnd()*4) grid[i,j]=g gr.bitmap.draw n, bblocks[g],(i-1)*ss,(j-1)*ss blockcount++ endif endif return HelpShowText: gosub PrepTextWindow gr.paint.copy pscore gosub HelpFindLine top$=trim$(t$,"[<>]") fin=0 do text.readln pText, in$ if left$(in$,1)="#" top$=mid$(in$,2) elseif in$="EOF" | left$(in$,1)="<" fin=1 elseif in$="" d_u.continue else gosub HelpPrepText list.size l, lines lines+=2 title$=top$ gosub PrepTextWindow gr.text.align 1 for i=1 to lines-2 list.get l,i,t$ gr.text.draw n, x,y,t$ y+=h next i bundle.get 1,"black",t gr.paint.copy t gr.text.align 1 gr.text.draw n, x,y+h,"Done" gr.text.width w, "More_" gr.text.align 3 gr.text.draw n, DISPLAY_W-x,y+h,"More" gr.render gosub AwaitTouch tx-=offset if txright | tybottom soundpool.play n, 2 d_u.break elseif ty>y & ty" text.open r, pText, gdir$+"help.txt" do text.readln pText, t$ if t$=search$ then d_u.break until t$="EOF" return !===== HelpPrepText: gr.paint.copy pScore list.create s, l left=x right=display_w-x i=0 % for breaking words too long x=1 s$=word$(in$,x)+" " do gr.text.width w, s$+word$(in$,x+1) if w>right-left if i>2 % trim a word too long to fit on one line t$=word$(in$,x+1) t=len(t$) for i=1 to t gr.text.width w,left$(t$,t-i) if w"" then list.add l, s$ s$="" else i=0 s$+=word$(in$,++x)+" " endif until word$(in$,x)="" if trim$(s$)<>"" then list.add l, s$ return !====== HideStuff: gr.hide oBall gr.hide oPaddles gr.hide oEgg if game=3 for i=1 to MAX_BALLS gr.hide oBalls[i] xBalls[i]=-1 next i elseif game=5 for i=1 to MAX_BUGS gr.hide oBugs[i] xBugs[i]=-1 next i endif for i=1 to 11 for j=1 to 11 grid[i,j]=0 next j next i return !====== LoadData: gosub OpenDB dim bBlocks[4] ScaleBitmaps(bBlocks[], gdir$+"blocks.png",ss, 4) bRightPanel=ScaleBitmap(gdir$+"right_panel.png",ACTUAL_H) bLeftPanel=ScaleBitmap(gdir$+"left_panel.png",ACTUAL_H) bInsert=ScaleBitmap( gdir$+"left_panel_insert.png",ACTUAL_H) font.load font, gdir$+"Gecko.ttf" gr.text.setfont soundpool.open 4 soundpool.load sbounce_paddle, sdir$+"bounce_paddle.wav" soundpool.load sball_miss, sdir$+"ball_miss.wav" soundpool.load sblock_smashed, sdir$+"block_smashed.wav" soundpool.load sbounce_grid, sdir$+"bounce_grid.wav" soundpool.load segg_hatch, sdir$+"egg_hatch.wav" soundpool.load snew_ball, sdir$+"new_ball.wav" soundpool.load snew_egg, sdir$+"new_egg.wav" soundpool.load ssuperball, sdir$+"superball.wav" return !====== Menu: bundle.put 1, "changed", 0 show_menu=1 i=1 do game=MenuSelect("Match,Smash,Juggle,Race,Squash,Options,Exit") if game=7 gosub UnloadData if ##$<>"" then run ##$ if isapk then exit else end elseif game=6 gosub SetGlobalVars bundle.put 1, "changed",0 do o=MenuSelect("&Options,Paddle Speed,Paddle Spin,Reset Hi Scores,Reset Custom Settings,Back") if o=1 paddle_speed=Slider("Paddle Speed",5,50,paddle_speed,0) elseif o=2 spin_angle=Slider("Paddle Spin",30,90,spin_angle,0) elseif o=3 o=MenuSelect("&Clear HiScores,Confirm,Cancel") if o=1 then sql.delete sdb, "scores", "" elseif o=4 o=MenuSelect("&Reset Custom Settings,Confirm,Cancel") if o=1 then gosub CustomResetVars endif until o=5 bundle.get 1, "changed",t if t then game=0 : gosub CustomSaveVars else t=shift(1,-game) if !band(helpflag,t) search$=game$[game] helpflag=bor(helpflag,t) gosub HelpShowText endif o=MenuSelect("&"+game$[game]+",Easy,Medium,Hard,Custom,Back") if o<>5 then skill=o : d_u.break endif until 0 return !====== Missed: misses-- if misses=0 then return gr.modify stat4, "text", "Balls "+int$(misses) gosub ReadyPaddles miss=1 return !====== MoveBall: hit=0 hits=max(hits,0) obx=bx oby=by if hits>hitbonus then t=bs*2 else t=bs if ang<>oang if ang>toradians(360) ang-=toradians(360) elseif angdisabled xBugs[i]+=sin(aBugs[i])*bugspeed yBugs[i]+=cos(aBugs[i])*bugspeed if rnd()>0.7 then gr.modify oBugs[i],"bitmap", bBug[1+floor(rnd()*8)] gr.modify oBugs[i], "x", xBugs[i]+offset, "y",yBugs[i] if xBugs[i]<0 | xBugs[i]>DISPLAY_W-ss | yBugs[i]<0 | yBugs[i]>DISPLAY_H-ss xBugs[i]=disabled gr.hide oBugs[i] misses-- gr.modify stat4, "text", "Lives "+int$(misses) soundpool.play n, sblock_smashed endif if gr_collision(oBall, oBugs[i]) xBugs[i]=disabled gr.hide oBugs[i] gosub Score hits++ if hits>hitbonus soundpool.play n, ssuperball misses+=1 gr.modify stat4, "text", "Lives "+int$(misses) hits=0 endif soundpool.play n, sblock_smashed endif endif next i return !===== NewEgg: if egg=1 then return gr.show oEgg soundpool.play n, snew_egg peace-=2 egg_timer=0 bs+=acc egg=1 i=floor(rnd()*7)+3 j=floor(rnd()*4) if j=0 if grid[1,i]>0 then misses=0 eggx=0 eggy=(i*ss)+ss/2 eggdx=6 eggdy=0 elseif j=1 if grid[12,i]>0 then misses=0 eggx=DISPLAY_W eggy=(i*ss)+ss/2 eggdx=-6 eggdy=0 elseif j=2 if grid[i,1]>0 then misses=0 eggx=(i*ss)+ss/2 eggy=0 eggdx=0 eggdy=6 elseif j=3 if grid[i,12]>0 then misses=0 eggx=(i*ss)+ss/2 eggy=DISPLAY_H eggdx=0 eggdy=-6 endif return !===== NewJuggleBall: if jballs=bCount then js+=(acc/4) : return for i=1 to bCount if xBalls[i]=-1 jballs++ gr.modify stat4, "text", "Balls "+int$(jballs) bs=js soundpool.play n, snew_egg xBalls[i]=DISPLAY_W/2 yBalls[i]=DISPLAY_H/2 gr.modify oBalls[i], "paint", colors[1+floor(rnd()*4)], "x",offset+xBalls[i], "y",yBalls[i] aBalls[i]=rnd()*360 gr.show oBalls[i] f_n.break endif next i return NewSquashBug: for i=1 to max_bugs if xBugs[i]=disabled n=1+floor(rnd()*hives) sx=xNests[n]-1 sy=yNests[n]-1 sx*=ss : sy*=ss xBugs[i]=sx yBugs[i]=sy aBugs[i]=toradians(rnd()*360) gr.show oBugs[i] soundpool.play n, snew_egg f_n.break endif next i bugspeed+=acc peace-- return !===== OnBackKey: if misses>0 let paused=1 back.resume endif gosub UnloadData if ##$<>"" then run ##$ if isapk then exit else end !===== OpenDB: file.exists exists, "../databases/scores.db" sql.open sdb, "scores.db" if !exists sql.new_table sdb, "scores", "game", "skill", "date", "name", "points" sql.new_table sdb, "custom", "game", "vars" gosub CustomResetVars endif return !====== PaddleBounce: miss=0 !LEFTLINE if bxDISPLAY_W-bEdge bx=DISPLAY_W-bEdge-1 if abs(by-ly)DISPLAY_H-bEdge by=DISPLAY_H-bEdge-1 if abs(bx-lx)hitbonus hits=0 else hits-=0.25 endif soundpool.play n, sbounce_paddle return !====== PaddleMove: olx=lx oly=ly if pendown gr.touch touched, px, py if touched pendown=1 if px>rEdge & py0 then gosub Score hits++ if hits>hitbonus soundpool.play n, ssuperball misses++ bs-=acc*2 hits=0 gr.modify stat4, "text", "Balls "+int$(misses) endif return !===== PaddleSmash: air=0 soundpool.play n, sbounce_paddle if hits>hitbonus hits=0 b=1 elseif b=1 b=0 gr.modify oBall, "paint", colors[1+floor(rnd()*4)] endif return !===== PaddleSquash: !LEFTLINE if bxDISPLAY_W-bEdge bx=DISPLAY_W-bEdge-1 hits=0 if abs(by-ly)DISPLAY_H-bEdge by=DISPLAY_H-bEdge-1 hits=0 if abs(bx-lx)"" then run ##$ if isapk then exit else end endif gr.bitmap.draw n,bTemp,0,0 gr.bitmap.delete bTemp gosub GetBackColor return !====== PrepJuggleBalls: gosub GetBackColor gr.rect n, 0,0,DISPLAY_W,DISPLAY_H gr.paint.copy colors[6] if !juggled gr.bitmap.drawinto.end juggled=1 dim oBalls[MAX_BALLS] dim aBalls[MAX_BALLS] dim xBalls[MAX_BALLS] dim yBalls[MAX_BALLS] for i=1 to MAX_BALLS gr.circle oBalls[i], 0,0,8 gr.hide oBalls[i] xBalls[i]=-1 next i gr.bitmap.drawinto.start bBuf else for i=1 to MAX_BALLS gr.hide oBalls[i] xBalls[i]=-1 next i endif gr.paint.copy colors[5] gosub NewJuggleBall return !===== PrepRaceGrid: gosub GetBackColor gr.rect n,0,0, DISPLAY_W,DISPLAY_H gr.paint.copy colors[6] for i=1 to blockcount do x=2+floor(rnd()*9) y=2+floor(rnd()*9) until grid[x,y]=0 j=floor(rnd()*15) j=4-floor(sqr(j)) if j=4 g=3 elseif j=3 g=3 elseif j=2 g=1 elseif j=1 g=2 endif if i=blockcount then g=4 grid[x,y]=g gr.bitmap.draw n, bBlocks[g], (x-1)*ss, (y-1)*ss if rnd()>0.6 then soundpool.play n, sbounce_grid else soundpool.play n,sbounce_paddle gr.render pause 150 next i return !===== PrepSmatchGrid: gosub GetBackColor gr.rect n,0,0, DISPLAY_W,DISPLAY_H !gr.paint.copy colors[6] for i=1 to 13 for j=1 to 13 grid[i,j]=0 next j next i dim shuffle[gw*gw] for i=1 to gw*gw shuffle[i]=i-1 next array.shuffle shuffle[] blockcount=0 b=0 j=1+floor((13-gw)/2) for i=1 to gw*gw t=shuffle[i] y=floor(t/gw) x=(t-(y*gw))+j y+=j if ++b>4 then b=1 g=floor(rnd()*16) g=4-floor(sqr(g)) g=max(1,g) if rnd()>gd then f_n.continue blockcount++ if game=2 then b=g grid[x,y]=b gr.bitmap.draw n, bBlocks[b], (x-1)*ss, (y-1)*ss gr.render if rnd()<25/(gw*gw*gd) % limit frequency of beeps based on number of blocks on grid if rnd()>0.4 then soundpool.play n, sbounce_paddle else soundpool.play n,sbounce_grid endif pause floor(1000/(gw*gw*gd)) % pause depending on number of blocks on grid next i return !===== PrepSquashGrid: gosub GetBackColor gr.rect n,0,0, DISPLAY_W,DISPLAY_H gr.paint.copy colors[6] if !bugs gr.bitmap.drawinto.end bugs=1 dim bBug[8] dim oBugs[max_bugs] ScaleBitmaps(bBug[], gdir$+"bug.png",ss,8) dim xBugs[max_bugs] dim yBugs[max_bugs] dim aBugs[max_bugs] for i=1 to max_bugs gr.bitmap.draw oBugs[i], bBug[1], 0,0 next i gr.bitmap.drawinto.start bBuf endif for i=1 to MAX_BUGS gr.hide oBugs[i] xBugs[i]=disabled next i endif for i=1 to 13 for j=1 to 13 grid[i,j]=0 next j next i dim xNests[hives] dim yNests[hives] for i=1 to hives x=6+floor(rnd()*5) y=6+floor(rnd()*5) gr.bitmap.draw n, bBlocks[4], (x-1)*ss, (y-1)*ss xNests[i]=x yNests[i]=y grid[x,y]=4 next i return !====== ReadyPaddles: soundpool.play n, sball_miss gr.hide oBall gr.show oPaddles lx=DISPLAY_W/2 ly=DISPLAY_H/2 gosub DrawStuff gr.render pause 800 if game<>3 then gr.show oBall soundpool.play n, snew_ball !if hits>hitbonus then bs/=2 hits=0: oldhits=0 oang=-1 !b=0 b=1+floor(rnd()*4) gr.modify oBall, "paint", colors[b] x=0 y=0 bpause=40 if game<3 | game=4 bx=(DISPLAY_H/2)+(rnd()*50-25) by=DISPLAY_H*0.85 ang=a0 else do bx=(rnd()*480)+80 by=(rnd()*480)+80 until grid[floor(bx/ss), floor(by/ss)]=0 ang=toradians(rnd()*360) endif gx=1+floor(bx/ss) : gy=1+floor(by/ss) gr.modify oBall, "x",bx+offset, "y",by return Score: points+=10+(floor(hits)*10) return !===== SetScreen: tLast=time() tDelay=30 gr.open 255, 0,0,0, ,0 gr.screen ACTUAL_W, ACTUAL_H DISPLAY_W=ACTUAL_H DISPLAY_H=ACTUAL_H bundle.put 1, "dw",DISPLAY_W bundle.put 1, "dh",DISPLAY_H ss=floor(ACTUAL_H/13) bigtext=ss smalltext=floor(ACTUAL_H/20) gosub LoadData !set the offset based on the right side panel gr.bitmap.size bRightPanel, rEdge,n rEdge=ACTUAL_W-rEdge offset=rEdge-DISPLAY_W bundle.put 1, "offset", offset !clip and add left edge to left panel gr.bitmap.size bLeftPanel, x,n gr.bitmap.crop t,bLeftPanel, x-offset,0, offset,ACTUAL_H gr.bitmap.delete bLeftPanel bLeftPanel=t gr.bitmap.drawinto.start bLeftPanel gr.bitmap.draw n,bInsert,0,0 gr.bitmap.drawinto.end gr.bitmap.delete bInsert !create and draw the graphic buffer at the bottom gr.bitmap.create bBuf, DISPLAY_W,DISPLAY_H gr.bitmap.draw oBuf, bBuf, offset ,0 !draw the paddles pWidth=floor(7*(ACTUAL_H/640)) %paddle width bEdge=pWidth*2 % bounce edge gr.color 255,152,102,72 gr.rect oPaddleL, 0,0,10,10 gr.rect oPaddleR, 0,0,10,10 gr.rect oPaddleT, 0,0,10,10 gr.rect oPaddleB, 0,0,10,10 gr.group oPaddles, oPaddleL, oPaddleR, oPaddleT, oPaddleB gr.hide oPaddles !draw the panels above the paddles gr.color 255,0,0,0 gr.text.size bigtext gr.paint.get t bundle.put 1, "black", t gr.rect n, 0,0,offset, DISPLAY_H gr.bitmap.draw n, bRightPanel, rEdge,0 gr.bitmap.size bLeftPanel, x,y gr.bitmap.draw n, bLeftPanel,offset-x, 0 !create color pointers for ball and draw it dim colors[6] gr.color 255, 255,255,0 % yellow gr.paint.get colors[1] gr.color 255, 0,200,0 % green gr.paint.get colors[2] gr.color 255, 0,0,255 % blue gr.paint.get colors[3] gr.color 255, 255,0,0 % red gr.paint.get colors[4] gr.color 255,200,200,200 % gray gr.paint.get colors[5] bundle.put 1, "gray", colors[5] gr.color 255,255,255,255 % white gr.paint.get colors[6] bundle.put 1, "white", colors[6] !draw the ball above the graphic buffer so it will always show gr.circle oBall,100,100,floor(8*(ACTUAL_H/640)) % adjust relative to original 640x640 resolution gr.hide oBall gr.color 255,250,100,100 gr.circle oEgg, -100,-100,floor(4*(ACTUAL_H/640)) !draw the status text gr.color 255, 0,0,0 gr.text.size smalltext gr.text.height h,u,d x=ACTUAL_W-(ACTUAL_W*0.025) y=ACTUAL_h*0.31 gr.text.align 3 gr.text.draw stat1, x,y,"" gr.text.draw stat2, x,y+h,"" gr.text.draw stat3, x,y+h*2,"" gr.text.draw stat4, x,y+h*3,"" !prep textwindow font gr.color 255,0,0,0 gr.text.size smalltext gr.text.setfont "sans" gr.paint.get pScore gr.text.bold 1 gr.color 255, 255,255,0 gr.paint.get pScoreY gr.bitmap.drawinto.start bBuf % start drawing into buffer !gr.rect n, 0,0, DISPLAY_W,DISPLAY_H gr.color 255,255,255,255 return !===== SetGlobalVars: a360=toradians(360) a270=toradians(270) a180=toradians(180) a90=toradians(90) a0=toradians(0) disabled=bnot(0) points=0 egg=0 egg_timer=0 bundle.get 1,"changed",t if skill=4 & t then gosub CustomSaveVars if !spin_angle then spin_angle=60 if !paddle_speed then paddle_speed=15 if !pLength then pLength=50 pLength*=(DISPLAY_H/640) hpLength=pLength/2 spin=toradians(spin_angle)/pLength sr=paddle_speed*(DISPLAY_H/640)/100 bs*=(DISPLAY_H/640)/10 acc*=(DISPLAY_H/640)/100 js=js*(DISPLAY_H/640)/10 bugspeed=bugspeed*(DISPLAY_H/640)/100 gd/=100 return !====== SetJuggleVars: MAX_BALLS=6 peace=150 hitbonus=100 if skill=1 bCount=3 pLength=70 js=30 acc=30 elseif skill=2 bCount=4 pLength=60 js=40 acc=40 elseif skill=3 bCount=5 pLength=50 js=50 acc=50 elseif skill=4 & show_menu=1 do o=MenuSelect("&Juggle Settings,Ball Count,Ball Speed,Paddle Width,Acceleration,Play") if o=1 bCount=Slider("Ball Count",2,6,bCount,0) elseif o=2 js=Slider("Ball Speed",10,200,js,0) elseif o=3 pLength=Slider("Paddle Width",20,100,pLength,0) elseif o=4 acc=Slider("Acceleration",10,100,acc,0) elseif o=5 d_u.break endif until 0 endif return !====== SetMatchVars: gw=5 gd=100 if skill=1 hitbonus=1.9 misses=5 pLength=70 bs=40 peace=400 acc=20 elseif skill=2 hitbonus=2.5 misses=4 pLength=60 bs=50 peace=300 acc=30 elseif skill=3 hitbonus=3 misses=3 pLength=50 bs=60 peace=200 acc=40 elseif skill=4 & show_menu do o=MenuSelect("&Match Settings,Ball Count,Ball Speed,Paddle Width,Egg Timer,"~ +"Acceleration,Bonus Threshold,Play") if o=1 misses=Slider("Ball Count",1,20,misses,0) elseif o=2 bs=Slider("Ball Speed",10,200,bs,0) elseif o=3 pLength=Slider("Paddle Width",20,100,pLength,0) elseif o=4 peace=Slider("Egg Timer",50,500,peace,0) elseif o=5 acc=Slider("Acceleration",10,100,acc,0) elseif o=6 hitbonus=Slider("Bonus Threshold",1.1,9.9,hitbonus,1) elseif o=7 d_u.break endif until 0 endif return !====== SetRaceVars: if skill=1 hitbonus=5 misses=6 pLength=70 bs=40 peace=50 acc=50 blockcount=6 elseif skill=2 hitbonus=5 misses=5 pLength=55 bs=50 peace=50 acc=70 blockcount=8 elseif skill=3 hitbonus=5 misses=4 pLength=40 bs=60 peace=50 acc=90 blockcount=10 elseif skill=4 & show_menu=1 do o=MenuSelect("&Race Settings,Ball Count,Ball Speed,Paddle Width,Egg Timer,"~ +"Acceleration,Bonus Threshold,Block Count,Play") if o=1 misses=Slider("Ball Count",1,20,misses,0) elseif o=2 bs=Slider("Ball Speed",10,200,bs,0) elseif o=3 pLength=Slider("Paddle Width",20,100,pLength,0) elseif o=4 peace=Slider("Egg Timer",50,500,peace,0) elseif o=5 acc=Slider("Acceleration",10,100,acc,0) elseif o=6 hitbonus=Slider("Bonus Threshold",3,12,hitbonus,0) elseif o=7 blockcount=Slider("Block Count",0,15,blockcount,0) elseif o=8 d_u.break endif until 0 endif return !===== SetSmashVars: if skill=1 hitbonus=5 misses=5 pLength=70 bs=40 peace=250 acc=20 if rnd()>0.7 gw=5 : gd=90 elseif rnd()>0.5 gw=7 : gd=46 else gw=9 : gd=28 endif elseif skill=2 hitbonus=6 misses=3 pLength=50 bs=60 peace=200 acc=30 if rnd()>0.8 gw=5 : gd=100 elseif rnd()>0.5 gw=7 : gd=50 else gw=9 : gd=30 endif elseif skill=3 hitbonus=7 misses=2 pLength=30 bs=80 peace=150 acc=40 if rnd()>0.9 gw=5 : gd=100 elseif rnd()>0.5 gw=7 : gd=70 else gw=9 : gd=42 endif elseif skill=4 & show_menu=1 do o=MenuSelect("&Smash Settings,Ball Count,Ball Speed,Paddle Width,Egg Timer,"~ +"Acceleration,Bonus Threshold,Grid Size,Play") if o=1 misses=Slider("Ball Count",1,20,misses,0) elseif o=2 bs=Slider("Ball Speed",10,200,bs,0) elseif o=3 pLength=Slider("Paddle Width",20,100,pLength,0) elseif o=4 peace=Slider("Egg Timer",50,500,peace,0) elseif o=5 acc=Slider("Acceleration",10,100,acc,0) elseif o=6 hitbonus=Slider("Bonus Threshold",1.1,9.9,hitbonus,1) elseif o=7 gw=Slider("Grid Size",3,11,gw,0) gd=Slider("Grid Density",10,100,gd,0) elseif o=8 d_u.break endif until 0 endif return !===== SetSquashVars: max_bugs=10 hitbonus=1.9 if skill=1 misses=6 pLength=70 bs=40 hives=2 bugspeed=20 peace=180 acc=2 elseif skill=2 misses=6 pLength=60 bs=50 hives=3 bugspeed=30 peace=150 acc=3 elseif skill=3 misses=3 pLength=50 bs=60 hives=4 bugspeed=40 peace=130 acc=4 elseif skill=4 & show_menu=1 do o=MenuSelect("&Race Settings,Lives,Ball Speed,Paddle Width,Hatch Rate"~ +",Bug Speed,Hive Count,Acceleration,Play") if o=1 misses=Slider("Lives",1,30,misses,0) elseif o=2 bs=Slider("Ball Speed",10,200,bs,0) elseif o=3 pLength=Slider("Paddle Width",20,100,pLength,0) elseif o=4 peace=Slider("Hatch Rate",50,500,peace,0) elseif o=5 bugspeed=Slider("Bug Speed",10,200,acc,0) elseif o=6 hives=Slider("Hive Count",1,9,hives,0) elseif o=7 acc=Slider("Acceleration",10,100,acc,0) elseif o=8 d_u.break endif until 0 endif return !===== PrepTextWindow: out$="" gr.paint.copy pScore gr.text.height h,u,d y=h*lines gosub GetBackColor gr.rect n,0,0,DISPLAY_W,DISPLAY_H gr.paint.copy colors[6] gr.text.height h,u,d x=DISPLAY_W*0.125 y=(DISPLAY_H-(y+h))/2 left=x-4 right=DISPLAY_W-left top=y-d bottom=DISPLAY_H-y+d+4 bundle.get 1,"black",b gr.paint.copy b gr.rect n, left,top,right,bottom t=y+h gr.paint.copy colors[5] gr.rect n, x,t,DISPLAY_W-x,DISPLAY_H-y+d gr.paint.copy colors[6] gr.text.align 2 gr.text.draw n, DISPLAY_W/2,y+h-d, title$ gr.paint.copy pScore gr.text.height h,u,d y=t+h x+=6 return !===== ShowHiScores: today=time() - (24*60*60*1000) w$=using$(,"game='%s' AND skill='%s'",int$(game),int$(skill)) sql.query cursor, sdb, "scores", "points,name,date,game,skill", w$, "points DESC" sql.query.length l, cursor lines=min(l,12) lines=max(lines,2) title$="Hi Scores" gosub PrepTextWindow for i=1 to lines sql.next d,cursor,p$,n$,d$ if d then f_n.break if d$=date$ gr.paint.copy pScoreY else gr.paint.copy pScore endif t=val(d$) n$=left$(n$,16) %name p$=trim$(p$) if t>today n$+=USING$("", " - %tI:%"" then GR.CLOSE return !========= functions: !========= FN.DEF DeleteBitmaps(o[], count) FOR i=1 TO count GR.BITMAP.DELETE o[i] NEXT i FN.RTN 1 FN.END FN.DEF DeleteBitmapsArray(o[], a, count) for i=1 to a FOR j=1 TO count GR.BITMAP.DELETE o[i,j] NEXT j NEXT i FN.RTN 1 FN.END !===== fn.def GetKeyChar(name$) kb.showing kbs if !kbs then kb.hide: fn.rtn 0 inkey$ c$ if c$="key 66" kb.hide fn.rtn 0 elseif c$="@" elseif c$="key 67" name$=left$(name$,len(name$)-1) elseif len(c$)=1 name$+=upper$(c$) name$=left$(name$,12) endif fn.rtn 1 fn.end !===== fn.def GetTextLine$(title$,default$) bundle.get 1, "gray", gray bundle.get 1, "black", black bundle.get 1, "offset", offset bundle.get 1, "dw", dw bundle.get 1, "dh", dh hw=dw/2 diahw=dw/3.5 do gr.touch touched,tx,ty pause 10 until !touched gr.paint.copy black gr.text.height h,u,d left=hw-diahw: right=hw+diahw: top=dh/6: bottom=top+(h*4) !left=hw-diahw: right=hw+diahw: top=hw-(h*2): bottom=hw+(h*2) gr.rect n, left-20,top-8, right+20, bottom+8 gr.paint.copy gray gr.rect n, left-16,top-4, right+16, bottom+4 gr.paint.copy black gr.text.size dh/16 gr.text.align 2 gr.text.draw n, hw, top-u, title$ gr.text.align 1 gr.text.draw n, left, top-u+(h*3), "Cancel" gr.text.align 3 gr.text.draw n, right, top-u+(h*3), "Okay" y=top+(h*2) fin=0 in$=upper$(default$) !gr.text.draw n, hw,y, in$ !gr.render !s$=in$ kb.show do fin=!GetKeyChar(&in$) gr.touch touched, tx,ty if in$<>s$ soundpool.play n,1 gr.paint.copy gray gr.rect n, left, top+h, right, top+h*2.5 gr.paint.copy black gr.text.align 2 gr.text.draw n, hw,y, in$ s$=in$ endif if touched do gr.touch touched,tx,ty pause 10 until !touched ty=floor((ty-top)/h) if ty=3 soundpool.play n,1 tx-=offset if txright-200 soundpool.play n, 1 kb.hide d_u.break elseif tx>left & tx"" gr.text.underline 1 gr.text.draw n, hw, bl-h, title$ gr.text.underline 0 endif for i=1 to l gr.text.draw n, hw, bl, items$[i] gr.text.width n, items$[i] w=max(w,n) bl+=h next i left=(hw)-(w/2) : right=hw+(w/2) do gr.render gr.touch touched, x,y x-=offset y-=top if touched if x>left & x0 & y0 soundpool.play n,1 do gr.touch touched,x,y pause 10 until !touched fn.rtn sel fn.end !===== fn.def ScaleBitmap(fn$,h) gr.bitmap.load t, fn$ gr.bitmap.size t, x,y ratio=x/y x=(h*ratio) gr.bitmap.scale b, t, x,h gr.bitmap.delete t fn.rtn b fn.end !====== FN.DEF ScaleBitmaps(a[], f$, ss, count) GR.BITMAP.LOAD o, f$ GR.BITMAP.SIZE o, w, h ! gr.bitmap.scale t, s, ss*count, ss ! gr.bitmap.delete s w/=count FOR i=1 TO count GR.BITMAP.CROP t, o, w*(i-1), 0, w, h gr.bitmap.scale a[i], t, ss,ss gr.bitmap.delete t NEXT i GR.BITMAP.DELETE o FN.RTN 1 FN.END FN.DEF LoadBitmaps(o[], f$, count) GR.BITMAP.LOAD t, f$ GR.BITMAP.SIZE t, w, h w/=count FOR i=1 TO count GR.BITMAP.CROP o[i], t, w*(i-1), 0, w, h NEXT i GR.BITMAP.DELETE t FN.RTN 1 FN.END !===== fn.def Slider(title$,min,max,current,r) new=SliderHelper(title$,min,max,current,r) if new=bnot(0) fn.rtn current else bundle.put 1,"changed",1 fn.rtn new endif fn.end !====== fn.def SliderHelper(title$,min,max,current,r) bundle.get 1, "gray", gray bundle.get 1, "black", black bundle.get 1, "offset", offset bundle.get 1, "dw", dw bundle.get 1, "dh", dh hw=dw/2 diahw=dw/3.5 gr.paint.copy black gr.text.height h,u,d left=hw-diahw: right=hw+diahw: top=hw-(h*2): bottom=hw+(h*2) gr.rect n, left-20,top-8, right+20, bottom+8 gr.paint.copy gray gr.rect n, left-16,top-4, right+16, bottom+4 gr.paint.copy black gr.text.size dh/16 gr.text.align 2 gr.text.draw n, hw, top-u, title$ t$="%."+int$(r)+"f" gr.text.draw n, hw, top-u+(h*2), using$(,t$,round(current,r)) gr.text.align 1 gr.text.draw n, left, top-u+(h*2), using$(,t$,round(min,r)) gr.text.draw n, left, top-u+(h*3), "Cancel" gr.text.align 3 gr.text.draw n, right, top-u+(h*2), using$(,t$,round(max,r)) gr.text.draw n, right, top-u+(h*3), "Okay" y=top+(h*1.5) gr.rect n, left,y-2, right,y+2 ratio=(right-left)/(max-min) x=left+(ratio*(current-min)) gr.circle n, x, y, 10 ox=x gr.render do gr.touch touched, x,y until touched do gr.touch touched, x,y until !touched y=floor((y-top)/h) if y=1 soundpool.play n, 1 x=x-left-offset new=x/ratio+min new=max(new,min) new=min(new,max) new=round(new,r) new=SliderHelper(title$,min,max,new,r) elseif y=3 x-=offset if xright-200 soundpool.play n, 1 new=current elseif x>left & x