15 puzzle game: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 5,775: | Line 5,775: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="FutureBasic"> |
||
// |
// 15 Puzzle // 26 september 2023 // |
||
begin globals |
begin globals |
||
Line 5,785: | Line 5,785: | ||
void local fn buildUI |
void local fn buildUI |
||
Long i, j, k = 1 // k is button number |
Long i, j, k = 1 // k is button number |
||
window 1, @" |
window 1, @"15 Puzzle", ( 0, 0, 200, 200 ), 3 |
||
for j = 3 to 0 step -1 : for i = 0 to 3 // Top to bottom, left to right |
for j = 3 to 0 step -1 : for i = 0 to 3 // Top to bottom, left to right |
||
button k, Yes, 1, @"", ( 20 + 40 * i, 20 + 40 * j , 40, 40 ), , NSBezelStyleShadowlessSquare |
button k, Yes, 1, @"", ( 20 + 40 * i, 20 + 40 * j , 40, 40 ), , NSBezelStyleShadowlessSquare |
||
Line 5,825: | Line 5,825: | ||
void local fn move ( n as Long ) |
void local fn move ( n as Long ) |
||
CFStringRef s |
CFStringRef s |
||
Long i, m, x = -1 // x is empty |
Long i, m, x = -1 // x is empty plot |
||
Bool ok |
Bool ok |
||
for i = 1 to 4 // see if clicked button is next to empty |
for i = 1 to 4 // see if clicked button is next to empty plot |
||
m = n + int( 2.6 * i - 6.5 ) // -4. -1, +1, +4 |
m = n + int( 2.6 * i - 6.5 ) // -4. -1, +1, +4 |
||
ok = Yes |
ok = Yes |