15 puzzle game: Difference between revisions
Content added Content deleted
Basicgames (talk | contribs) |
Basicgames (talk | contribs) |
||
Line 4,620: | Line 4,620: | ||
=={{header|Craft Basic}}== |
=={{header|Craft Basic}}== |
||
[[File:15 puzzle craft basic.png|thumb]] |
[[File:15 puzzle craft basic.png|thumb]] |
||
<syntaxhighlight lang="basic"> |
<syntaxhighlight lang="basic">rem 15 Puzzle example game |
||
rem written in Craft Basic |
|||
rem by Gemino Smothers 2023 |
|||
rem www.basicgames.xyz |
|||
define size = 16, correct = 0, moves = 0 |
define size = 16, correct = 0, moves = 0 |
||
Line 4,647: | Line 4,647: | ||
let x = 0 |
let x = 0 |
||
let y = 30 |
let y = 30 |
||
⚫ | |||
⚫ | |||
do |
|||
if x = 112 then |
if x = 112 then |
||
Line 4,664: | Line 4,663: | ||
buttonform x, y, 25, 20 |
buttonform x, y, 25, 20 |
||
next i |
|||
⚫ | |||
loop i < size |
|||
formid 17 |
formid 17 |
||
Line 4,711: | Line 4,708: | ||
updateform |
updateform |
||
for i = 0 to size - 1 |
|||
do |
|||
formid i + 1 |
formid i + 1 |
||
Line 4,720: | Line 4,715: | ||
let list[i] = 0 |
let list[i] = 0 |
||
⚫ | |||
next i |
|||
⚫ | |||
let i = 0 |
let i = 0 |
||
do |
do |
||
if i = 14 then |
|||
⚫ | |||
do |
|||
⚫ | |||
formtext n |
|||
⚫ | |||
⚫ | |||
break |
|||
endif |
|||
⚫ | |||
let n = ( int: (rnd) * 14 ) + 1 |
let n = ( int: (rnd) * 14 ) + 1 |
||
let s = 0 |
let s = 0 |
||
⚫ | |||
for c = 0 to i - 1 |
|||
do |
|||
if n = list[c] then |
if n = list[c] then |
||
let s = 1 |
let s = 1 |
||
break |
break c |
||
endif |
endif |
||
next c |
|||
⚫ | |||
if s = 0 and list[i] = 0 then |
if s = 0 and list[i] = 0 then |
||
Line 4,756: | Line 4,760: | ||
let list[i] = n |
let list[i] = n |
||
⚫ | |||
let i = i + 1 |
let i = i + 1 |
||
endif |
endif |
||
let f = f + 1 |
|||
wait |
wait |
||
next f |
|||
⚫ | |||
loop i < size - 1 |
loop i < size - 1 |
||
Line 4,818: | Line 4,821: | ||
if click = 21 then |
if click = 21 then |
||
alert "15 Puzzle |
alert "15 Puzzle", newline, "by Gemino Smothers 2023 ", newline, " www.basicgames.xyz" |
||
endif |
endif |
||
Line 4,905: | Line 4,908: | ||
let correct = 0 |
let correct = 0 |
||
let i = 0 |
|||
for i = 0 to size - 2 |
|||
do |
|||
if list[i] = i + 1 then |
if list[i] = i + 1 then |
||
let correct = correct + 1 |
let correct = correct + 1 |
||
⚫ | |||
⚫ | |||
⚫ | |||
endif |
endif |
||
next i |
|||
let i = i + 1 |
|||
formid 18 |
|||
⚫ | |||
⚫ | |||
updateform |
|||
if correct = size - 1 then |
if correct = size - 1 then |
||
wait |
|||
alert "You win! Moves: ", moves |
alert "You win! Moves: ", moves |
||