Is there a function that will sense if a moving object (say, a ball) is no longer changing its x-coordinate after about 3 seconds or so? I made a pong game, and sometimes it gets stuck going straight up an down, and it would be nice to reset it if that happens. Thanks
Offline
SD7 wrote:
Is there a function that will sense if a moving object (say, a ball) is no longer changing its x-coordinate after about 3 seconds or so? I made a pong game, and sometimes it gets stuck going straight up an down, and it would be nice to reset it if that happens. Thanks
set [moving v] to true.
repeat until <moving = false> {
set [xpos v] to (x position).
wait 0.5 seconds.
if <(x position) = (xpos)> {
set [moving v] to false.
}
}
The above script checks every 0.5 seconds to see if it is moving at all. Then, add this:
set [xpos v] to (xposition).
wait 3 seconds.
if <(x position) = (xpos)> {
code if it hasn't moved here.
}
Put that all in the "repeat until" and everything after it, in the first and second script, into a forever loop. I think that will work.
Last edited by Greenatic (2011-09-15 20:56:06)
Offline