tengo este scrip que ubica 4 pares de cartas en el room
dice as?
[gml]repeat (200)
{
again = 0
gotoy = 0
gotox = 0
if irandom(2) > 1 then
gotoy=16
else
gotoy=224
hrow = irandom(4)
if hrow = 1 then
gotox = 16
if hrow = 2 then
gotox = 192
if hrow = 3 then
gotox = 368
if hrow = 4 then
gotox = 544
if place_meeting(gotox,gotoy,card_properties) then
again = 1
if again = 0 then
{
x=gotox
y=gotoy
exit
}
}[/gml]
el punto es q quisiera ubicar 8 pares, que debo cambiar, lo hice as? pero no funciona:
[gml]repeat (200)
{
again = 0
gotoy = 0
gotox = 0
if irandom(4) > 1 then
gotoy=16
else
gotoy=224
gotoy=120
gotoy=328
hrow = irandom(8)
if hrow = 1 then
gotox = 16
if hrow = 2 then
gotox = 192
if hrow = 3 then
gotox = 368
if hrow = 4 then
gotox = 544
if hrow = 5 then
gotox = 16
if hrow = 6 then
gotox = 192
if hrow = 7 then
gotox = 368
if hrow = 8 then
gotox = 544
if place_meeting(gotox,gotoy,card_properties) then
again = 1
if again = 0 then
{
x=gotox
y=gotoy
exit
}
}
[/gml]
qu? creen que est? haciendo mal?
gracias
pues tus dos c?digos hacen exactamente lo mismo intenta no poner los mismos valores a partir del hrow=4.
p.d.
tu c?digo es muy optimizable.
edit: ayer no tenia mucho tiempo as? que ahora te ayudo aun mas.
lo que haces mal es esta parte del segundo codigo codigo que en realidad hace lo mismo que el primero.
[gml]
hrow = irandom(8)
if hrow = 1 then
gotox = 16
if hrow = 2 then
gotox = 192
if hrow = 3 then
gotox = 368
if hrow = 4 then
gotox = 544
if hrow = 5 then
gotox = 16
if hrow = 6 then
gotox = 192
if hrow = 7 then
gotox = 368
if hrow = 8 then
gotox = 544[/gml]
mira bien y tienes repetidos los mismos n?meros a partir del 5 y como es un numero aleatorio entre 8 y hay dos de cada 16, 192, 368 y 544 entonces eso es lo mismo que escoger un numero aleatorio entre 4 pero esta vez sin repetir alg?n numero, es como escribir 1/4 y 2/8 son lo mismo pero se escriben distinto, as? que me imagino que lo que necesitas es no repetir a partir del 544 si no seguir con la serie.
P.D. te dejo un c?digo optimizado no creo que repare tu error pero igual prueba (cambia el random(4) por random(8 ) ), si no entiendes este script mejor usa el que tu hiciste
[gml]
gotox=card_properties.x
gotoy=card_properties.y
while(place_meeting(gotox,gotoy,card_properties)){
choose(gotoy=16,gotoy=224)
hrow=floor(random(4))
gotox=16*(max(hrow*12-hrow+1,1))
}
x=gotox
y=gotoy
[/gml]