16 puzzle game: Difference between revisions

Line 203:
str63 board, startPos, winBoard
 
void local fn buildWndinit
window 1,,(0,0,340,340)
int x
Line 220:
button _restrt,,,@"Redo", (270,270,50,50),,NSBezelStyleTexturedSquare
button _help ,,,@"Help", (270, 20,50,50),,NSBezelStyleTexturedSquare
for rx = 1 to 16
end fn
winBoard += chr$(rx)
 
void local fn init
int r
for r = 1 to 16
winBoard += chr$(r)
next
board = winBoard
fn buildWnd
end fn
 
Line 245 ⟶ 240:
 
void local fn move( tag as int )
int r, a, b, cd, rc = (tag mod 10)
select tag / 10
case _up : ad = rc+4 : b = a + 8 : c = +4
case _right : ad = rc * 4 -1 : brc *= a4 - 2 : c = -1
case _down : ad = rc + 12 -4 : brc += a12 - 8 : c = -4
case _leftelse : ad = rc+1 *: 4rc - 3 : b = arc +* 24 :- c3 = +1
end select
for r = arc to brc + 2 * d step cd
swap board[r], board[r+cd]
next
if board == winBoard then window 1, @"!!! YOU WON !!!" : text,,fn colorRed
68

edits