Loops problem with send
Posted: Mon Jun 23, 2014 9:49 am
Hello,
I wanted to create a Frogger game, user move a graphic (frog) avoiding cars.
I wanted to keep simple the code, so I wrote the code just for one car (a graphic), then I copied and pasted six cars.
This is the car code, when the game starts every cars receive the messages gioco (a loop to move car) and controint (a loop to check intersection with frog):
#####
on gioco
move me relative 400,0 in 3 sec
move me relative -400,0 in 1 tick
if the giostat of this card is "runni" then
send gioco to me in 0.1 sec
end if
end gioco
on controint
if intersect(graphic frog, me) then
set the giostat of this card to "stop"
stop moving me
answer "Aaaaahh! The frog died!"
end if
if the giostat of this card is "runni" then
send controint to me in 0.1 sec
end if
end controint
#####
My problem is that with more than one car, loops random freeze and restart.
I know that I could create a single message that move all cars and check intersection, but with my way I can change game configuration just with dragging, coping, pasting.
I suspect that problem is in send message, do you know a better way to move many graphic with every graphic containing is own move message?
I wanted to create a Frogger game, user move a graphic (frog) avoiding cars.
I wanted to keep simple the code, so I wrote the code just for one car (a graphic), then I copied and pasted six cars.
This is the car code, when the game starts every cars receive the messages gioco (a loop to move car) and controint (a loop to check intersection with frog):
#####
on gioco
move me relative 400,0 in 3 sec
move me relative -400,0 in 1 tick
if the giostat of this card is "runni" then
send gioco to me in 0.1 sec
end if
end gioco
on controint
if intersect(graphic frog, me) then
set the giostat of this card to "stop"
stop moving me
answer "Aaaaahh! The frog died!"
end if
if the giostat of this card is "runni" then
send controint to me in 0.1 sec
end if
end controint
#####
My problem is that with more than one car, loops random freeze and restart.

I know that I could create a single message that move all cars and check intersection, but with my way I can change game configuration just with dragging, coping, pasting.
I suspect that problem is in send message, do you know a better way to move many graphic with every graphic containing is own move message?