I'm working on adding a pause function to my game (here), but the code I used for the movement of the enemies makes it so that it will always do that movement
The script for enemy movement is:
Forever
---Glide [pick random 3 to 5] secs to x [pick random -225 to 225] and y [pick random -40 to 180]
So that they glide around the screen randomly, but that code overwrites anything else, so even if I tell it to wait for "pause" variable to be true, it still moves. Does anyone have any code idea that either a) make the enemies do the same movement but will stop when it's paused or b) a way to make the current code respond to "pause" being true.
Thanks
Offline
SD7 wrote:
I'm working on adding a pause function to my game (here), but the code I used for the movement of the enemies makes it so that it will always do that movement
The script for enemy movement is:
Forever
---Glide [pick random 3 to 5] secs to x [pick random -225 to 225] and y [pick random -40 to 180]
So that they glide around the screen randomly, but that code overwrites anything else, so even if I tell it to wait for "pause" variable to be true, it still moves. Does anyone have any code idea that either a) make the enemies do the same movement but will stop when it's paused or b) a way to make the current code respond to "pause" being true.
Thanks
Forever if <(pause) = [true]> Glide end end
Offline
That's exactly what I have, but takes about a second and a half to actually stop them. And then they don't all stop at once- you click pause and (there's three enemies), first stops, then second one stops, then the third, not all at once.
Offline
Forever Glide if <(pause) = [true]> stop all end end
Last edited by shiguy101 (2012-05-03 12:18:55)
Offline
But then if you click the pause button again, will it resume where it left off? I figured it would restart the game, like clicking the flag again (well, he11, I figured since it says stop all, the pause button wouldn't work anymore, because it's stopped)
Offline
shiguy101 wrote:
Forever Glide if <(pause) = [true]> stop script end end
this is what I meant
Offline
Tried that, didn't do anything.
I did try
Forever
-- if <(PAUSE) = [0]>
------- if <(Red 1 Move) = [true]>
---------------Glide
But again, that didn't stop them instantly, they glided around for about a second before coming to a stop
Offline
you may also need
When [Sprite1] Clicked set [ pause v ] to (true) broadcast [start v] When I receive [start v] Glide
Last edited by shiguy101 (2012-05-03 12:40:46)
Offline
The problem is that the glide block takes the full 3 to 5 seconds before moving on to the next block in the stack -- so if you set pause to true when the sprite has just started gliding, it can take a full 5 seconds before it actually stops.
To avoid this, you can make your own glide method that mimics the block, but also checks for the pause variable every so often.
Offline
Fixed it SD7
Forever if <(Bomber Move) = [True]> Set (X Destin) to (pick random (-170) to (170)) Set (Y Destin) to (pick random (50) to (150)) repeat until <<([abs v] of ((x position) - (X Destin))) < [5]> and <([abs v] of ((y position) - (Y Destin))) = [5]>> // Change the equal sign to less than. Somehow I couldn't when typing scratch blocks if <(PAUSE) = [0]> if <(x position) < (X Destin)> Change x by [1.5] end if <(x position) > (X Destin)> Change x by [-1.5] end if <(y position) > (Y Destin)> Change y by [-1.5] end if <(y position) < (Y Destin)> Change y by [1.5] end end end end end
Last edited by itsmomito (2012-05-03 14:40:19)
Offline