15 puzzle game: Difference between revisions

Content added Content deleted
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">'15 Puzzle example game
<syntaxhighlight lang="basic">rem 15 Puzzle example game
'written in Craft Basic
rem written in Craft Basic
'by Gemino Smothers 2023
rem by Gemino Smothers 2023
'www.basicgames.xyz
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
let i = 0


for i = 0 to size - 1
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
let i = i + 1

loop i < size


formid 17
formid 17
Line 4,711: Line 4,708:
updateform
updateform


let i = 0
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
let i = i + 1


loop i < size
next i


let t = 0
let i = 0
let i = 0


do
do


let f = 0
if i = 14 then


let n = 120 - t
do

formid i + 1
formtext n
updateform

let list[i] = n

break

endif

for f = 0 to size - 1


let n = ( int: (rnd) * 14 ) + 1
let n = ( int: (rnd) * 14 ) + 1
let s = 0
let s = 0
let c = 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


let c = c + 1
next c

loop c < i


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 t = t + n
let i = i + 1
let i = i + 1


endif
endif

let f = f + 1


wait
wait


next f
loop f = < size - 1


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 - by Gemino Smothers 2023 - www.basicgames.xyz"
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

formid 18
formtext "Correct: ", correct
updateform


endif
endif


next i
let i = i + 1


formid 18
loop i < size - 1
formtext "Correct: ", correct
updateform


if correct = size - 1 then
if correct = size - 1 then


wait
alert "You win! Moves: ", moves
alert "You win! Moves: ", moves