I'm trying to make a sliding puzzle type program.I can pick a tile(object) and make it slide around.Can I take a variable and replace it with the object number (move object left variable,33)?
If so,the I should also be able to take that variable and randomize the tiles. Problem is. I can't figure out the right syntax.
Thanks,Please.
This a striped code of the original.
`Variables`
BoxX=0
BoxY=-1
BoxZ=34
MoveR=BoxX+33
MoveD=BoxZ-33
`Make 9 Tiles
for tiles = 1 to 9
make object box tiles,33,2,33
next tiles
`Set Tiles Into Place
position object 1,BoxX, BoxY,BoxZ :cell1=0
position object 2,BoxX+33,BoxY,BoxZ :cell2=1
position object 3,BoxX+66,BoxY,BoxZ :cell3=1
position object 4,BoxX, BoxY,BoxZ-33 :cell4=1
position object 5,BoxX+33,BoxY,BoxZ-33 :cell5=1
position object 6,BoxX+66,BoxY,BoxZ-33 :cell6=1
position object 7,BoxX, BoxY,BoxZ-66 :cell7=1
position object 8,BoxX+33,BoxY,BoxZ-66 :cell8=1
position object 9,BoxX+66,BoxY,BoxZ-66 :cell9=1
color object 1,rgb(0,100,100)
color object 2,rgb(0,255,255)
color object 3,rgb(100,100,0)
color object 4,rgb(200,200,0)
color object 5,rgb(100,0,100)
color object 6,rgb(100,0,200)
color object 7,rgb(100,200,200)
color object 8,rgb(100,100,200)
color object 9,rgb(200,200,200)
`Set Camera
position camera xCam+30,yCam+120,zCam+0
xrotate camera Xang+90
do
`Keep Mouse Position Updated
Mx=MouseX() : My=MouseY() : Mc=MouseClick()
gosub CellCheck
hide object 1
gosub canmove
`Moves Tile 2 to tile 1
if T1 and cell1=0 and Mc=1
gosub tile1
endif
`moves Tile 1 to Tile 2
if T2 and cell2=0 and Mc=1
gosub tile2
endif
loop
CellCheck:
T1= Mx>260 and Mx<438 and My>129 and My<303
T2= Mx>440 and Mx<614 and My>129 and My<303
T3= Mx>618 and Mx<793 and My>129 and My<303
T4= Mx>260 and Mx<438 and My>308 and My<438
T5= Mx>440 and Mx<614 and My>308 and My<438
T6= Mx>618 and Mx<793 and My>308 and My<438
T7= Mx>260 and Mx<438 and My>486 and My<660
T8= Mx>440 and Mx<614 and My>486 and My<660
T9= Mx>618 and Mx<793 and My>486 and My<660
return
canmove:
if cell1=0 :canmove=1 :else :canmove=0 :cell1=1 :endif
if cell2=0 :canmove=1 :else :canmove=0 :cell2=1 :endif
if cell3=0 :canmove=1 :else :canmove=0 :cell3=1 :endif
if cell4=0 :canmove=1 :else :canmove=0 :cell4=1 :endif
if cell5=0 :canmove=1 :else :canmove=0 :cell5=1 :endif
if cell6=0 :canmove=1 :else :canmove=0 :cell6=1 :endif
if cell7=0 :canmove=1 :else :canmove=0 :cell7=1 :endif
if cell8=0 :canmove=1 :else :canmove=0 :cell8=1 :endif
if cell9=0 :canmove=1 :else :canmove=0 :cell9=1 :endif
return
tile1:
move object left 2,33
Mc=0
Cell1=1
Cell2=0
return
tile2:
move object right 2,33
Mc=0
Cell1=0
Cell2=1
return