Random number help please urgent
Hi all
i have an actor that spawns a actor self.pos.x to random(30,290) which works fine
but i want to do the following but don't how to do it in GS:
Variable called game.randomPosX = random(30,290)
first instance: actor gets spawned at 280, 270, 275 etc,
what i want is that
if the the actor was spawned at 280, then the next instance i want it to spawn on the left hand side of the screen.
example
if randomposx >=0 and <=160 the actor has spawned on the left hand side
if randomposx >=160 and <= 320 the actor has spawned on the right side
thanks
i have an actor that spawns a actor self.pos.x to random(30,290) which works fine
but i want to do the following but don't how to do it in GS:
Variable called game.randomPosX = random(30,290)
first instance: actor gets spawned at 280, 270, 275 etc,
what i want is that
if the the actor was spawned at 280, then the next instance i want it to spawn on the left hand side of the screen.
example
if randomposx >=0 and <=160 the actor has spawned on the left hand side
if randomposx >=160 and <= 320 the actor has spawned on the right side
thanks
Comments
By the sound of it you'll need to split it up into two spawning actions, right, then left, then right, etc; - if I've understood you correctly.
So something like: Make a boolean attribute called Switch
When Switch is false
Change attribute game.randomPosX to random(161, 319)
-- then spawn your actor with it's x pos. as randomPosX
change attribute Switch to true
When Switch is True
Change attribute game.randomPosX to random(1, 159)
-- then spawn your actor with it's x pos. as randomPosX
change attribute Switch to false
hope that's what you're after and it helps out...
----------------------------------------------
http://davidgriffinapps.co.uk/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
first and second spawn..:)
If you want the first spawn straight away, put this first:
Change attribute game.randomPosX to random(161, 319)
-- then spawn your actor with it's x pos. as randomPosX
change attribute Switch to true
---then...
Rule
When Switch is true
Timer After 5 seconds
Change attribute game.randomPosX to random(1, 159)
-- then spawn your actor with it's x pos. as randomPosX
change attribute Switch to false
Rule
When Switch is false
Timer After 5 seconds
Change attribute game.randomPosX to random(161, 319)
-- then spawn your actor with it's x pos. as randomPosX
change attribute Switch to true
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps