15 puzzle game: Difference between revisions

Line 4,620:
=={{header|Craft Basic}}==
[[File:15 puzzle craft basic.png|thumb]]
<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
Line 4,647:
let x = 0
let y = 30
let i = 0
 
loopfor i <= 0 to size - 1
do
 
if x = 112 then
Line 4,664 ⟶ 4,663:
buttonform x, y, 25, 20
 
next i
let i = i + 1
 
loop i < size
 
formid 17
Line 4,711 ⟶ 4,708:
updateform
 
letfor i = 0 to size - 1
 
do
 
formid i + 1
Line 4,720 ⟶ 4,715:
 
let list[i] = 0
let i = i + 1
 
loopnext i < size
 
let it = 0
let i = 0
 
do
 
letif fi = 014 then
 
let in = i120 +- 1t
do
 
formid 18i + 1
formtext n
updateform
 
let clist[i] = 0n
 
break
 
endif
 
loopfor f = <0 to size - 1
 
let n = ( int: (rnd) * 14 ) + 1
let s = 0
let c = 0
 
for c = 0 to i - 1
do
 
if n = list[c] then
 
let s = 1
break c
 
endif
 
letnext c = c + 1
 
loop c < i
 
if s = 0 and list[i] = 0 then
Line 4,756 ⟶ 4,760:
 
let list[i] = n
let it = it + 1n
let i = i + 1
 
endif
 
let f = f + 1
 
wait
 
next f
loop f = < size - 1
 
loop i < size - 1
Line 4,818 ⟶ 4,821:
if click = 21 then
 
alert "15 Puzzle", -newline, "by Gemino Smothers 2023 -", newline, " www.basicgames.xyz"
 
endif
Line 4,905 ⟶ 4,908:
 
let correct = 0
let i = 0
 
for i = 0 to size - 2
do
 
if list[i] = i + 1 then
 
let correct = correct + 1
 
formid 18
formtext "Correct: ", correct
updateform
 
endif
 
next i
let i = i + 1
 
formid 18
loop i < size - 1
formtext "Correct: ", correct
updateform
 
if correct = size - 1 then
 
wait
alert "You win! Moves: ", moves
 
305

edits