Hi,
here is a puzzle game, Magic24.
To solve this puzzle you must have this contruction:
01 02 03 04 05
06 07 08 09 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24
Include "ss.inc"
OpenWindow 320,320,1
fo= LoadFont "gfxmagic/bne2.ttf",28,1
Dim xm, ym, ibx, iax, ras, bDir as sys
Dim x1, y1, z1, a, skey as sys
Dim Map(64), Buf(26) as sys
num = LoadImage "gfxmagic/blocks.png",25
wav1= LoadWav "gfxmagic/clic.wav"
wav2= LoadWav "gfxmagic/attention.wav"
Sub MoveBloc()
iF ras=0 Then Exit Sub
iF bDir=1
DrawImage num,x1,y1,iax
x1 +=2
z1 +=2
iF z1=64
ras=0
z1 =0
x1 = x1/64
y1 = y1/64
ibx = y1*5 + x1
Map(ibx) =iax
End iF
ElseiF bDir=2
DrawImage num,x1,y1,iax
x1 -=2
z1 +=2
iF z1 =64
ras=0
z1 =0
x1 = x1/64
y1 = y1/64
ibx = y1*5 + x1
Map(ibx) =iax
End iF
ElseiF bDir=3
DrawImage num,x1,y1,iax
y1 -=2
z1 +=2
iF z1 =64
ras=0
z1 =0
x1 = x1/64
y1 = y1/64
ibx = y1*5 + x1
Map(ibx) =iax
End iF
ElseiF bDir=4
DrawImage num,x1,y1,iax
y1 +=2
z1 +=2
iF z1 =64
ras=0
z1 =0
x1 = x1/64
y1 = y1/64
ibx = y1*5 + x1
Map(ibx) =iax
End iF
End iF
End Sub
Sub IsBloc()
iF ras >0 Then Exit Sub
xm = xMouse() /64
ym = yMouse() /64
ibx = ym*5 + xm
iF MouseButton()=1
iax = Map(ibx)
iF iax=0 Then Exit Sub
iF Map(ibx+1) =0
Ras =1
bDir =1
Map(ibx) =0
x1 = xm*64
y1 = ym*64
PlayWav wav1
ElseiF Map(ibx-1) =0 and xm >0
ras =1
bDir=2
Map(ibx) =0
x1 = xm*64
y1 = ym*64
PlayWav wav1
ElseiF Map(ibx-5) =0 and ym >0
Ras =1
bDir=3
Map(ibx) =0
x1 = xm*64
y1 = ym*64
PlayWav wav1
ElseiF Map(ibx+5) =0
ras =1
bDir=4
Map(ibx) =0
x1 = xm*64
y1 = ym*64
PlayWav wav1
End iF
End iF
End Sub
Sub ShowMap()
Long px, py, pz, pa
For py=0 To 4
For px=0 To 4
pa = py*5 + px
pz = Map(pa)
DrawImage num,px*64,py*64,pz
Next
Next
End Sub
Function Buffer(long rd) as long
Long ix=0
While ix <24
iF Buf(ix)=rd
Return 1
End iF
ix +=1
Wend
ix =0
While ix <24
iF Buf(ix) =0
Buf(ix) = rd
Exit Function
End iF
ix +=1
Wend
End Function
Sub Start()
Long pa, px, pz
For pa=0 To 64
Map(pa)=255
Next
ras=0
z1=0
a=0
For pa=0 To 24
Buf(pa) =0
Map(pa) =0
Next
While px <24
pa = Rnd(1,24)
pz = Buffer(pa)
iF pz <> 1
Map(px) = pa
px +=1
End iF
Wend
End Sub
Sub Ready()
iF a=1 Then Exit Sub
For ix=0 To 23
iF Map(ix) <> ix+1 Then Exit Sub
Next
PlayWav wav2
a=1
End Sub
Start()
While Key(27)=0
Cls 0,0,0
ShowMap
IsBloc
MoveBloc
Ready
iF a=1
DrawText fo,60,100," YOU GOT IT ",RGB(255,255,255)
DrawText fo,34,140,"PRESS SPACE BAR",RGB(255,255,255)
End iF
Redraw
Wait 5
iF Key(32) and sKey=0
Start()
sKey=1
End iF
iF Key(32)=0 then sKey=0
Wend
CloseWindow
.