#!/usr/local/bin/yabasic version$="0.04" : reld$=" (Dec 03, 1999)" ini.ROWS=10 : ini.COLS=10 : ini.NB=10 rem ini.NB=int(ini.ROWS*ini.COLS/5) gui.nc=ini.ROWS*ini.COLS+2 : rem number of clickable regions :-) import gui import ini dx=38 : dy=40 : happy$=":-)" : sad$=":-(" open window 320,300 Label NewGame clear screen print "Yet Another Mine Sweeper, by Hermang Mansilla, hmansilla@usa.net" ? "Version ",version$,reld$," Not finished yet, released under GPL\n" marginx=10 : marginy=12 :usefont=2 Tag(marginx,marginy, usefont, 20,"Mine Sweeper") usefont=1 : marginy=27 Tag(marginx,marginy, usefont, 20,"for Yabasic") face$=happy$ : ini.face$=ini.happy$ Bombs=ini.NB InitBoard(dx,dy) ? "Press q to Quit, n for New Game, use Mouse to click on the slots" ? "Use right mouse button to mark a flag, left button to uncover the slot" rem ini.ShowBoard(2,dx+260,dy) ini.ShowBoard(1,dx,dy) putbit ini.face$ to 130,3 Tag(170,marginy, usefont, 12,"Left Bombs:") Tag(270,marginy, usefont, 3,str$(Bombs,"%2.0f")) label Mainloop gosub ShowStatus if face$=sad$ goto AskNewGame if Bombs=0 then Gosub VerifyWin fi k$=inkey$ if k$="n" goto NewGame if left$(k$,2)="MB" gosub CheckClick if k$="q" end goto Mainloop end Label CheckClick n=0 n=ClickedOnArea(k$,100) if n>0 then if mouseb(k$)<0 then clickrow=mod(n-1,10)+1 clickcol=int((n-1)/10)+1 rem print clickrow,clickcol,mouseb(k$) MakeMove(clickrow,clickcol,mouseb(k$)) if face$=happy$ ini.ShowBoard(1,dx,dy) fi fi return sub MakeMove(cr,cc,mb) ini.dl(1,cr,cc)=1 if mb=-3 then if ini.Board$(1,cr,cc)="f" then ini.Board$(1,cr,cc)="?" Bombs=Bombs+1 else ini.Board$(1,cr,cc)="f" Bombs=Bombs-1 fi Tag(270,marginy, usefont, 3,str$(Bombs,"%2.0f")) else if ini.Board$(1,cr,cc)<>"f" then if ini.Board$(2,cr,cc)="B" then face$=sad$ : ini.face$=ini.sad$ putbit ini.face$ to 130,1 ini.ShowBoard(2,dx,dy) else ini.Hint(cr,cc) fi fi fi end sub Label ShowStatus print @ ( 3, 14) face$ print @ ( 3, 15) "Bombs left : "; print @ (16, 15) Bombs; return Label AskNewGame input "\nNew Game (y/n)" yn$ if yn$="y" then clear window goto NewGame else end fi goto AskNewGame Label VerifyWin hits=0 beep for row=1 to ini.ROWS for col=1 to ini.COLS if ini.Board$(2,row,col)="B" and ini.Board$(1,row,col)="f" hits=hits+1 next col next row if hits=ini.NB then print "\n Yes , You Did it ...!\n" goto AskNewGame fi return