Estructuras de control ( IF... THEN)
Estoy intentando crear un frame sript que me coja de forma aleatoria diferentes actores y los ponga en la partitura en sitios concretos. También tiene que asegurarse de que los actores no se repiten que son siempre diferentes. El código que utilizo es el siguiente:
global dificultat,a,b,c,d,e,f,g
on exitFrame me
i = 1
if dificultat = 1 then
a=1
b=1
c=1
d=1
e=1
f=1
g=1
repeat while i<=7
if i = 1 then
x = random (12)
a =x
set the member of sprite 14 = "R_"&x
i = i + 1
end if
if i = 2 then
x = random (12)
b =x
if b = a then
x = random (12)
b =x
end if
set the member of sprite 15 = "R_"&x
i = i + 1
end if
if i = 3 then
x = random (12)
c =x
if c = a or c = b then
x = random (12)
c =x
end if
set the member of sprite 16 = "R_"&x
i = i + 1
end if
if i = 4 then
x = random (12)
d =x
if d = a or b or c then
x = random (12)
d =x
end if
set the member of sprite 17 = "R_"&x
i = i + 1
end if
if i = 5 then
x = random (12)
e =x
if e = a or b or c or d then
x = random (12)
e =x
end if
set the member of sprite 18 = "R_"&x
i = i + 1
end if
if i = 6 then
x = random (12)
f =x
if f = a or b or c or d or e then
x = random (12)
f =x
end if
set the member of sprite 19 = "R_"&x
i = i + 1
end if
if i = 7 then
x = random (12)
g =x
if g = a or b or c or d or e or f then
x = random (12)
g =x
end if
set the member of sprite 20 = "R_"&x
i = i + 1
end if
end repeat
end if
end if
end
Como no funcionaba ya que a partir de la variable C empieza a repetir actores, estuve controlando todo el procedimiento a través de la ventana Messege y de Debugger. He podido comprobar que la estructura de control por ejemplo IF d = a or b or c then siempre la lee aunque los valores no sean iguales. Hay alguna cosa que no hago bien?
global dificultat,a,b,c,d,e,f,g
on exitFrame me
i = 1
if dificultat = 1 then
a=1
b=1
c=1
d=1
e=1
f=1
g=1
repeat while i<=7
if i = 1 then
x = random (12)
a =x
set the member of sprite 14 = "R_"&x
i = i + 1
end if
if i = 2 then
x = random (12)
b =x
if b = a then
x = random (12)
b =x
end if
set the member of sprite 15 = "R_"&x
i = i + 1
end if
if i = 3 then
x = random (12)
c =x
if c = a or c = b then
x = random (12)
c =x
end if
set the member of sprite 16 = "R_"&x
i = i + 1
end if
if i = 4 then
x = random (12)
d =x
if d = a or b or c then
x = random (12)
d =x
end if
set the member of sprite 17 = "R_"&x
i = i + 1
end if
if i = 5 then
x = random (12)
e =x
if e = a or b or c or d then
x = random (12)
e =x
end if
set the member of sprite 18 = "R_"&x
i = i + 1
end if
if i = 6 then
x = random (12)
f =x
if f = a or b or c or d or e then
x = random (12)
f =x
end if
set the member of sprite 19 = "R_"&x
i = i + 1
end if
if i = 7 then
x = random (12)
g =x
if g = a or b or c or d or e or f then
x = random (12)
g =x
end if
set the member of sprite 20 = "R_"&x
i = i + 1
end if
end repeat
end if
end if
end
Como no funcionaba ya que a partir de la variable C empieza a repetir actores, estuve controlando todo el procedimiento a través de la ventana Messege y de Debugger. He podido comprobar que la estructura de control por ejemplo IF d = a or b or c then siempre la lee aunque los valores no sean iguales. Hay alguna cosa que no hago bien?
1 Respuesta
Respuesta de bedelludrica
1