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