Como crear un puzzle game con director8

Hola: como crear un puzzle game con director8
Gracias

1 Respuesta

Respuesta
1
Este es un puzzle deslizable de ocho huecos y 7 piezas.
ESto se lo debes vincular a las siete piezas.
On mouseDown
Pulsar (the clickon)
end
Esta es la movie script que controla todo.
global g_hueco_x,g_hueco_y
on startmovie
g_hueco_x=1
g_hueco_y=1
repeat with i=1 to 8
puppetsprite i,true
end repeat
aleatoriedad
end
on aleatoriedad
repeat with i=0 to 100
a1=random(8)
a2=random(8)
l1=sprite(a1).loc
l2=sprite(a2).loc
sprite(a1).loc=l2
sprite(a2).loc=l1
updatestage
end repeat
end
on pulsar cuadro
h=sprite(cuadro).loch
v=sprite(cuadro).locv
--144 es el ancho y alto del cada cuadrado
pos_x=(h/144)+float(1/2)+1
pos_y=(v/144)+float(1/2)+1
if (g_hueco_x=pos_x-1) and (g_hueco_y=pos_y) then
Desplazar(cuadro,-1,0)
else if (g_hueco_x=pos_x) and (g_hueco_y=pos_y-1) then
desplazar(cuadro,0,-1)
else if (g_hueco_x=pos_x+1) and (g_hueco_y=pos_y) then
desplazar(cuadro,1,0)
else if (g_hueco_x=pos_x) and (g_hueco_y=pos_y+1) then
desplazar(cuadro,0,1)
end if
end
on desplazar (cuadro, mx,my)
h=sprite(cuadro).loch
v=sprite(cuadro).locv
posf_x=h+144*mx
posf_y=v+144*my
repeat with i=0 to 40
sprite(cuadro).loch=(float(i)/40)*posf_x+(1-(float(i)/40))*h
sprite(cuadro).locv=(float(i)/40)*posf_y+(1-(float(i)/40))*v
updatestage
end repeat
g_hueco_x=g_hueco_x-mx
g_hueco_y=g_hueco_y-my
if has_acertado() then alert "¡LO HAS CONSEGUIDO!"
end
ON HAS_ACERTADO
repeat with i=1 to 8
h=sprite(i).loch
v=sprite(i).locv
--144 es el ancho y alto del cada cuadrado
pos_x=(h/144)+float(1/2)+1
pos_y=(v/144)+float(1/2)+1
if (sprite(i).member.name.word[1]=string(pos_x)) and \
(sprite(i).member.name.word[2]=string(pos_y)) then
return 1
else
return 0
end if
end repeat
end

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas