Minesweeper game: Difference between revisions

m
Line 2,882:
 
=={{header|EasyLang}}==
[https://easylang.onlinedev/apps/mine-sweeper.html Run it]
<syntaxhighlight lang="text">
len cell[] 56
Line 2,894:
no_time = 0
.
procfunc getind r c . ind .
ind = -1
if r >= 0 and r <= 6 and c >= 0 and c <= 7
ind = r * 8 + c + 1
.
return ind
.
proc draw_cell ind h . .
Line 2,940 ⟶ 2,941:
flag[ind] = 0
color 686
call draw_cell ind cnt[ind]
if cnt[ind] = 0
ind -= 1
Line 2,948 ⟶ 2,949:
for c = c0 - 1 to c0 + 1
if r <> r0 or c <> c0
callopen getind r c ind
call open ind
.
.
Line 2,963:
color 353
.
call draw_cell ind m
.
.
Line 2,983:
.
if nc = 8
call outp 484 "Well done"
call show_mines -1
state = 1
else
call outp 464 8 - nm & " mines left"
.
.
Line 2,993:
if cell[ind] < 2 and flag[ind] = 0
if cell[ind] = 1
call show_mines -1
color 686
call draw_cell ind -2
call outp 844 "B O O M !"
state = 1
else
call open ind
call upd_info
.
.
Line 3,012:
cell[ind] = 0
flag[ind] = 0
call draw_cell ind 0
.
n = 8
Line 3,024:
for rx = r - 1 to r + 1
for cx = c - 1 to c + 1
callind = getind rx cx ind
if ind > -1
cnt[ind] += 1
Line 3,032:
.
.
call initvars
call outp 464 ""
textsize 4
move 5 93
Line 3,050:
rect 33 11
.
callindx = getind ((mouse_y - 2) div 12) ((mouse_x - 2) div 12 indx)
ticks0 = ticks
elif state = 3
call start
.
.
on mouse_up
if state = 0 and indx <> -1
call test indx
.
indx = -1
Line 3,069:
state = 3
elif no_time = 0 and ticks > 3000
call outp 844 "B O O M !"
call show_mines -2
state = 2
timer 1
Line 3,082:
opt = -3
.
call draw_cell indx opt
call upd_info
.
indx = -1
Line 3,102:
.
.
call start
</syntaxhighlight>
 
1,983

edits