Flappybird style spawning (the barriers)

evertevert Member Posts: 266
edited November 2014 in Working with GS (Mac)

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

Comments

  • evertevert Member Posts: 266
  • evertevert Member Posts: 266

    @mattbutlerstudios i know this tutorial, but here they spawn above each other. i DON'T want them to spawn above each other, ever.

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    Set up 2 spawners, each spawning at opposite times.

  • evertevert Member Posts: 266

    @MattButlerStudios said:
    Set up 2 spawners, each spawning at opposite times.

    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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2014

    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

  • evertevert Member Posts: 266
    edited December 2014

    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**_

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2014

    @evert said:
    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**_

    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

  • ChechesoftChechesoft Member, PRO Posts: 171

    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.

Sign In or Register to comment.