16 puzzle game: Difference between revisions

Line 203:
str63 board, startPos, winBoard
 
=void local fn buildWnd
window 1,,(0,0,340,340)
int x
Line 222:
end fn
 
void local fn init
int r
for r = 1 to 16
Line 231:
end fn
 
void local fn drawBoard
int c = 1, x, y, z
cls
Line 244:
end fn
 
void local fn move( tag as int )
int t, r, rc = (tag mod 10)
select tag / 10
case _left : rc*=4
mid$(board, rc-3, 4) = mid$(board, rc-2, 3) + mid$(board,rc -3,1)
case _right : rc*=4
Line 267:
end fn
 
void local fn newGame
window 1, @"16 PUZZLE GAME"
int r, c, s
for r = 1 to 16
sswap board[r], = board[rnd(16)]
c = board[s]
board[s] = board[r]
board[r] = c
next
startPos = board
Line 281 ⟶ 278:
end fn
 
void local fn ask( tag as long )
CFStringRef s1, s2 : int btn
select tag
Line 303 ⟶ 300:
end fn
 
void local fn doDialog(ev as long, tag as long)
select ev
case _btnClick : if tag > _end then fn move( tag ) else fn ask( tag )
Line 318 ⟶ 315:
{{out}}
[[File:16 Puzzle Game.png]]
 
=={{header|Go}}==
<syntaxhighlight lang="go">package main
68

edits