# MatchIcons .bas # match the icons memory game # f$ ="yBasIcons1" dim a(6,6),b(6,6) # ytop: # draw the grid draw -1 for j=0 to 6 x = 6+24*j y = 20+24*j draw x,20,x,140 if j<6 then draw 6,y,150,y next j gosub filla() # nt=0:f=0 while while x=fn pen(0) : y = fn pen(2) i1=int((x-6)/24)+1 j1=int((y-20)/24)+1 wend (b(j1,i1)=0) rem * show the 1st tap * gosub show(j1,i1) while x=fn pen(0) : y = fn pen(2) i2=int((x-6)/24)+1 j2=int((y-20)/24)+1 wend (b(j2,i2)=0) rem * show the 2nd tap * gosub show(j2,i2) nt=nt+1 if a(j1,i1) <> a(j2,i2) t = fn wait(0.5) gosub cover(j1,i1) gosub cover(j2,i2) else f=f+1 endif t$=str$(nt)+" "+str$(f)+" " draw t$,80,148 rem * check for all uncovered * if f >= 15 then draw "You Win",60,61,1 draw "You Win",60,85,1 endif wend (f >= 15) # restart after a tap at the bottom while x=fn pen(0) : y=fn pen(2) wend (y>150) goto ytop end # # routine to fill the entire grid sub filla() for j=1 to 5 for i=1 to 6 gosub cover(j,i) next i next j for j=1 to 5 for i=1 to 3 n=1 + ((j*6+i) mod 15) a(j,i)=n : a(j,i+3)=n next i next j for k=0 to 30 x1 = 1+rnd(6) : x2=1+rnd(6) y1 = 1+rnd(5) : y2=1+rnd(5) t=a(y1,x1):a(y1,x1)=a(y2,x2) a(y2,x2)=t next k end sub # # routine to cover up a square sub cover(j,i) y = 22+24*(j-1) x = 8+24*(i-1) draw x,y,21,21,7 b(j,i)=0 end sub # # routine to show a square sub show(j,i) y = 22+24*(j-1) x = 8+24*(i-1) n = 2000+a(j, i)-1 draw x,y,21,21,-7 draw x,y,0,n,400,f$ b(j,i)=1 end sub end # run # # (c)2000 rhn@hotpaw.com # free for use with HotPaw Basic