Flappybird style spawning (the barriers)
evert
Member Posts: 266
hey there,
i'm making a game (no not flappybird) but i have objects spawning like the barriers in flappybird.
But i don't want them to spawn above each other! so they are random but still once in a while they spawn above each other.
How can i avoid that?
Thanks
New game!: [Snake Rage]https://itunes.apple.com/us/app/snake-rage/id1463859909
Comments
bump
New game!: [Snake Rage]https://itunes.apple.com/us/app/snake-rage/id1463859909
Try this:
www.mbstudios.co | Free Stuff
@mattbutlerstudios i know this tutorial, but here they spawn above each other. i DON'T want them to spawn above each other, ever.
New game!: [Snake Rage]https://itunes.apple.com/us/app/snake-rage/id1463859909
Set up 2 spawners, each spawning at opposite times.
www.mbstudios.co | Free Stuff
This is what i have at the moment, but the spawning is random, so at a certain moment they will always spawn at the same time. and i need to avoid that
New game!: [Snake Rage]https://itunes.apple.com/us/app/snake-rage/id1463859909
I'm not quite exactly sure what you're going for but if you need two spawners to never overlap their times, consider using a timer that fires on odd numbered seconds and another that fires on even numbered seconds.
For example, one timer would fire at 4, 8, 12, 16, 20, etc.
The other timer would fire at 3, 9, 15, 21, 27, etc.
How to achieve this?
When mod(round(game.time-3),6)=0 ... would be the odd numbered timer
When mod(round(game.time),4)=0 ... would be the even timer
I haven't tested that but try it out and let me know if it works for you.
Actually, you could use a Timer instead:
When attribute self.Time≥3
Spawn actor [actor name]
Timer every 6 seconds
Spawn actor [actor name]
That would achieve the same odd numbered sequence (3, 9, 15, 21, 27, etc.).
And for even:
Timer every 4 seconds
Spawn actor [actor name]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
At the moment i have: _**timer: every 1sec
change attribute self.timing to random(0.5,2)
**_
and then a rule:
_** self.timing = 1
spawn actor**_
New game!: [Snake Rage]https://itunes.apple.com/us/app/snake-rage/id1463859909
What is the point of that? You're using a timer to create a 33.3% probability of spawning a single actor every second. Random(0.5,2) isn't technically correct syntax since the random() function takes whole numbers as arguments but apparently it will return 0, 1 or 2. I guess it rounds 0.5 down to 0. So a third of the time your rule will be true. I'm not sure how that prevents overlapping spawn times. Did you try my suggestion with timers?
By the way, if you did want a random decimal value (i.e. tenths) you would use random(5,20)/10 which would return a number between 5/10 and 20/10, or 0.5 and 2.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
For Ripple Munch, my jelly fish random spawned, but if they overlapped I set a rule that If collide or overlap and out of the play zone (so this dont apply once they are moving in game), move to another random point.