Randomly Spawning Obstacles

PhiliePhilie PRO Posts: 240
edited May 2012 in Working with GS (Mac)
I am looking to have an endless game that isn't too long in width. The character stays in the same position, and the rest of the game has motion velocity set so the obstacles/objects come towars the character.

Since I hope that the user plays this game multiple times, I need these objects/obstacles to randomly spawn, in different places every time. The problem is, I'm not sure what the best way to do that is. Do I put them in to the game, and have it change the x and y automatically or have a spawner?

I have about 10-15 objects/obstacles, all different widths and heights, so I don't want them to happen at the same time, no overlapping. Think of Jetpack Joyride in this sense.

Any help is greatly appreciated!

Cheers,
Matt

Best Answer

  • FluxGamesFluxGames Posts: 33
    edited June 2012 Accepted Answer
    @tshirtbooth, do you know how to make the actor collide with the platforms smoother in this template? Because now, the bigger speed the actor gains the longer it falls through the actor.

    Sorry for bad English.

    //MJ

Answers

  • lukey5227lukey5227 Member Posts: 111
    Well, either works. Just, if you spawn each one, make sure to destroy the ones that have already passed the end of the screen.
  • PhiliePhilie PRO Posts: 240
    Ok, thanks @lukey5226 - but I am looking for a more in-depth answer.
  • PhiliePhilie PRO Posts: 240
    Anyone?
  • jckmcgrawjckmcgraw Member Posts: 647
    @philie

    I've seen a doodle jump template somewhere... :/ I realize that I don't know exactly who made it and that it is vertical, but it might have some important info. I know that it is infinate, and platforms never overlap.

    If you can't find it, I can look through some files on my computer when I get home and see if I still have it.

    I hope this helps,
    Jack McGraw
  • FluxGamesFluxGames Member Posts: 33
    @philie

    I've seen a doodle jump template somewhere... :/ I realize that I don't know exactly who made it and that it is vertical, but it might have some important info. I know that it is infinate, and platforms never overlap.

    If you can't find it, I can look through some files on my computer when I get home and see if I still have it.

    I hope this helps,
    Jack McGraw
    Hey, have you found it? I know i've seen it somwhere around here, but i just can't find it! Please let me know if you have it! :)

  • DanDaMan123DanDaMan123 Member Posts: 216
    What you could do is have an attribute that determines which obstacle is spawned. Then, every time an obstacle is spawned the attribute becomes a random value to determine the next obstacle.

    Also, if you want them to never overlap, what you could do is have an actor that spawns the obstacles. If the actor was touching one of the already spawned obstacles, (overlaps or collides with: actor of tag: obstacle) then it would not be able to spawn any new obstacles. Then, once it wasn't touching anything, (because the obstacles had moved) it would be able to spawn again. This way worked for me with spawning platforms after about three other failed attempts, so it should work.
Sign In or Register to comment.