0,]']>S}Wup8d%qy)6o;]Aφl0hP! 0݌43!!v۝8Bm3zu2Tv2Tv             ̻̻̻ݻݻ̻ϻ̻̻̻̻̻̻ݻ ̻̻̻ܻܻ̿ ̻̻̻̻̻̻ ϻ̻̻ݻݻ |"""(((((((((((((((((((((((((((  0*_______________??_=V==V=}=V==V==V=}}=V==V=}=V==V==V=}}=V==V=}=V==V==V=}}=V==V=}=V==V==V=}}~~_?__?_?__?_?__?_?__?_?__?_?__?_?__?_?__?\\\\\\z\j\Z\J\*\\\\\\\\v\f\\\\\\\x\h\\\\\\\z\j\Z\J\*\\\\\\\\v\f\\\\\\\z\j\\\\\\\v\f\V\F\&\\\\\\\\v\f\\\\\\\u\e\\\\\\\v\f\V\F\&\\\\\\\\v\f\\\\\\\u\e\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_?__?_?__?_?___?_?_?__?_?__?_?___?_?\\\\\\v\f\V\F\&\\\\\\\\z\j\<<<<<<x and myy end music_mode="off" if music_mode=="on" then music(0,0,0,true) end size_x=4 size_y=4 num_over=0 num_win=0 game_mode="8x8" -- Sprite ID lookup tables (replaces long if/elseif chains) local SPR = { ["4x4"] = { unrevealed=20, revealed=19, flag=10, bomb=9, count=function(n) return n end -- sprite ID == count directly }, ["8x8"] = { unrevealed=34, revealed=33, flag=26, bomb=25, count=function(n) return n>0 and (10+n) or nil end -- 11-18 } } function init() pixs={} text_lose={ "you lose 0_0","you noop @_@", "me grandma\nplaying\nbetteru OoO!", "stop play -_-","Go f***\nsleep!! 0^0", "are you\ncrazy! 0_o","broooo o-o" } id_lose={262,264,296,294} id_link=256 text_win={ "ya bebe","you win","ya bro","uo lala", "hahah","let's Go","my bro","is you win","lalalalal" } id_win={266,298} text_link="" char=0 link_mode="0_0" time_now=0 t=1 cam={x=size_x*2,y=size_y*2} num_ml=0 cell=5 bomb=0 pos_bomb={} timer=30 mlt=false mrt=false grid={} num_bomb=0 num_black=0 new_grid() new_bomb() grid_count() GameStat="Menu" end function draw_link() local x=240-33 local y=86 spr(400,180,33,0,1,0,0,7,5) -- Draw link character based on current mood if link_mode=="0_0" then spr(ml and 258 or 256,x,y,0,1,0,0,2,2) elseif link_mode=="x_x" then spr(id_link,x,y,0,1,0,0,2,2) elseif link_mode=="0_0?" then if ml then link_mode="0_0" end spr(260,x,y,0,1,0,0,2,2) draw_text("???",183,36,15) if t%720==0 then link_mode="0_0" end elseif link_mode=="0o0!" then spr(id_link,x,y,0,1,0,0,2,2) end spr(336,240-42,93,0,1,0,0,4,2) print(text_link,183,36,15,true,1,true) end -- Spawns 4 particles at grid cell position function new_pix(gx,gy) local num = 0 if game_mode == "4x4" then num = 79 else num = 63 end for i=1,4 do abb(pixs,{ x=gx*cell, y=gy*cell, l=60, vx=rnd(1,2)*(rnd(0,2)-1), vy=rnd(2,3)*-1, id=num+i }) end end -- Updates and draws all particles function draw_pix() for i=#pixs,1,-1 do local p=pixs[i] p.l=p.l-1 p.vy=min(p.vy+0.3,5) p.x=p.x+p.vx p.y=p.y+p.vy if p.l<0 then del(pixs,i) else spr(p.id,p.x+cam.x,p.y+cam.y,0) end end end -- Initializes empty grid cells function new_grid() for y=1,size_y do grid[y]={} for x=1,size_x do grid[y][x]={bomb=false,revealed=false,revealed_time=false,count=0,flag=false,kk=false} end end end -- Debug: shows bomb positions function get_pos_bomb() for y=1,size_y do for x=1,size_x do if grid[y][x].bomb then spr(11,x*cell,y*cell,0) end end end end init() function TIC() cls(15) mx,my,ml,mb,mr=mouse() if GameStat=="Game" then upd_grid() elseif GameStat=="Menu" then upd_menu() end if GameStat=="Game" or GameStat=="Over" or GameStat=="Win" then draw_grid() if GameStat=="Over" then GameOver() elseif GameStat=="Win" then draw_win() end UI() elseif GameStat=="Menu" then draw_menu() end t=t+1 mlt=ml mrt=mr end function upd_menu() -- Arrow buttons change grid size if ml and not mlt and hitbox(142,117,8,8) then size_x=size_x-1 end if ml and not mlt and hitbox(216,117,8,8) then size_x=size_x+1 end if ml and not mlt and hitbox(181,82,8,8) then size_y=size_y+1 end if ml and not mlt and hitbox(181,103,8,8) then size_y=size_y-1 end -- Start game button if ml and not mlt and hitbox(64-7*3,50,50,14) then num_over=0; num_win=0 init(); GameStat="Game"; win() end -- Toggle 4x4 / 8x8 mode if ml and not mlt and hitbox(135,54,20,20) then game_mode=game_mode=="4x4" and "8x8" or "4x4" end if ml and not mlt and hitbox(64-7*3,90,50,14) then exit() end -- Toggle music if ml and not mlt and hitbox(134,5,20,11) then if music_mode=="on" then music_mode="off"; music(3,0,0,false) else music_mode="on"; music(0,0,0,true) end end size_x=max(8,size_x) size_y=max(8,size_y) end function draw_menu() cls(13) rectb(0,0,240,136,12) rect(128,0,112,136,14) rectb(128,0,112,136,12) rect(129,77,110,58,15) rect(130,78,108,55,12) -- me XeonBrix spr(480,1,136-17,0,1,0,0,2,2) print("By:\nXeonBrix",18,136-14,12,true,1,true) -- ok king spr(482,128-17,136-17,0,1,0,0,2,2) print("play test:\nok king",72,136-14,12,true,1,true) -- Arrow buttons with hover highlight spr(ml and hitbox(142,117,8,8) and 226 or 210,142,117,0) spr(ml and hitbox(216,117,8,8) and 227 or 211,216,117,0) spr(ml and hitbox(181,82,8,8) and 224 or 208,181,82,0) spr(ml and hitbox(181,103,8,8) and 225 or 209,181,103,0) print("Music\n "..music_mode,135,6,12,true,1,true) print_outline("SIZE X: "..size_x,165,118,true,1,12,14) print_outline("SIZE Y: "..size_y,165,94,true,1,12,14) spr(256,141,30,0,1,0,0,2,2) spr(348,132,37,0,1,0,0,4,5) -- Mode icon display local s=SPR[game_mode] rect(135,54,10,10,15); spr(s.unrevealed,136+(game_mode=="8x8" and 0 or 2),55+(game_mode=="8x8" and 0 or 2),0) rect(135+10,54,10,10,15); spr(s.revealed,136+10+(game_mode=="8x8" and 0 or 2),55+(game_mode=="8x8" and 0 or 2),0) print(game_mode,136,68,15) spr(455,175-4,32,11,1,0,0,5,4) spr(460,201-4,18,11,1,0,0,4,4) print_3d("PLAY",64-7*3,50,false,2,12,14,3) print_3d("EXIT",64-7*3,90,false,2,12,14,3) end function draw_win() timer=timer-1 -- Pick random win message once if timer<29 and timer>27 then text_link=text_win[rnd(#text_win)] id_link = id_win[rnd(#id_win)] end print_3d("YOU WIN",64-7*6,64,false,2,12,14,3) print_outline("YOU WIN",64-7*6,64,false,2,12,14) if ml and not mlt and timer<1 then init(); num_win=num_win+1; GameStat="Game" end end -- Text with 1px outline function print_outline(t,x,y,f,m,c1,c2) print(t,x,y+1,c2,true,m,f) print(t,x,y-1,c2,true,m,f) print(t,x+1,y,c2,true,m,f) print(t,x-1,y,c2,true,m,f) print(t,x,y,c1,true,m,f) end -- Text with drop shadow depth l function print_3d(t,x,y,f,m,c1,c2,l) for i=1,l do print(t,x,y+i,c2,true,m,f) end print(t,x,y,c1,true,m,f) end function GameOver() timer=timer-1 -- Set lose message once at start if timer<29 and timer>27 then text_link=text_lose[rnd(#text_lose)] id_link=id_lose[rnd(#id_lose)] music(1,0,0,false) end if ml and not mlt and timer<1 then math.randomseed(time()*1000) init(); music(3,0,0,false) if music_mode=="on" then music(0,0,0,true) end GameStat="Game" end print_3d("Game Over",64-7*7,64,false,2,12,14,3) print_outline("Game Over",64-7*7,64,false,2,12,14) end function UI() rectb(0,0,240,136,12) rect(128,0,111,136,14) rectb(128,0,112,136,12) rectb(128,109,112,32,12) -- Stats display print_3d("BOMBS : "..bomb,132,126,true,1,12,13,1) print_3d("BLACK : "..num_black,132,113,true,1,12,13,1) print_3d("Lose : "..num_over,190,113,true,1,12,13,1) print_3d("Win : "..num_win,190,126,true,1,12,13,1) -- UI divider lines line(128+56,109,128+56,136,12) line(128,122,240,122,12) line(129,110,183,110,13); line(185,110,238,110,13) line(129,123,183,123,13); line(185,123,238,123,13) rect(129,73,52-2,36,15) rect(130,74,50-2,33,12) -- Keyboard camera pan if btn(0) then cam.y=cam.y+1 elseif btn(1) then cam.y=cam.y-1 end if btn(2) then cam.x=cam.x+1 elseif btn(3) then cam.x=cam.x-1 end -- Mouse camera pan buttons if ml and hitbox(140-2,90-1,8,8) then spr(226,140-2,90-1,0); cam.x=cam.x+0.5 else spr(210,140-2,90-1,0) end if ml and hitbox(160+2,90-1,8,8) then spr(227,160+2,90-1,0); cam.x=cam.x-0.5 else spr(211,160+2,90-1,0) end if ml and hitbox(150,80-2,8,8) then spr(224,150,80-2,0); cam.y=cam.y+0.5 else spr(208,150,80-2,0) end if ml and hitbox(150,100-2,8,8) then spr(225,150,100-2,0); cam.y=cam.y-0.5 else spr(209,150,100-2,0) end -- Menu button if ml and not mlt and hitbox(240-10,136-10,8,8) then GameStat="Menu" end spr(185,240-10,136-10,0) draw_link() end function upd_grid() local gx,gy=(mx-cam.x)//cell,(my-cam.y)//cell revealed_time() -- Random link reaction when hovering a bomb if end_grid(gx,gy) and not grid[gy][gx].flag then if t%320==0 and rnd()<0.50 and grid[gy][gx].bomb then link_mode="0_0?" end end if ml and not mlt and end_grid(gx,gy) and not grid[gy][gx].flag then num_ml=num_ml+1 if not grid[gy][gx].bomb then reveal_cell(gx,gy); win() else if num_ml<2 then -- First click on bomb: move it away reveal_cell(gx,gy) grid[gy][gx].bomb=false num_bomb=num_bomb-1 new_bomb(); grid_count() else -- Reveal all bombs on loss for y=1,size_y do for x=1,size_x do if grid[y][x].bomb then grid[y][x].revealed=true end end end num_over=num_over+1 link_mode="x_x"; GameStat="Over" end end end -- Right click: toggle flag / second flag state if mr and not mrt and end_grid(gx,gy) then local cell=grid[gy][gx] if not cell.flag then cell.flag=true; cell.kk=true else cell.kk=false; cell.flag=false end end end function draw_grid() -- Set cell size by mode cell=game_mode=="4x4" and 5 or 9 local s=SPR[game_mode] for y=1,size_y do for x=1,size_x do local sx,sy=x*cell+cam.x,y*cell+cam.y local g=grid[y][x] if g.revealed or g.revealedtime then spr(s.revealed,sx,sy,0) if not g.bomb then -- Draw number sprite if count > 0 local cid=s.count(g.count) if cid then spr(cid,sx,sy,0) end else -- Revealed bomb: show flag icon if flagged spr(g.flag and s.flag or s.bomb,sx,sy,0) end else -- Unrevealed cell spr(s.unrevealed,sx,sy,0) if g.flag then spr(s.flag,sx,sy,0) end end end end rectb(cell-1+cam.x,cell-1+cam.y,size_x*cell+1,size_y*cell+1,12) draw_pix() end -- Checks if all non-bomb cells are revealed function win() local num_kk=0 for y=1,size_y do for x=1,size_x do if not grid[y][x].revealed then num_kk=num_kk+1 end end end num_black=num_kk if num_kk==bomb then link_mode="0o0!"; GameStat="Win" end end -- Returns true if x,y is inside the grid and within left panel function end_grid(x,y) return x>0 and x0 and y0 and mx<128 and my>0 and my<136 end -- Recursively reveals cell and neighbors if count==0 function reveal_cell(x,y) if not grid[y] or not grid[y][x] then return end local c=grid[y][x] if c.revealed or c.bomb or c.flag then return end c.revealed=true new_pix(x,y) sfx(1,"D-4",11,0,15) if c.count==0 then for dy=-1,1 do for dx=-1,1 do if not(dx==0 and dy==0) then reveal_cell(x+dx,y+dy) end end end end end -- Flash all cells revealed briefly (timer-based) function revealed_time() time_now=time_now-1 local state=time_now>=0 for y=1,size_y do for x=1,size_x do grid[y][x].revealed_time=state end end end