Spawning Actors randomly for a Terrain without overlapping?

I have and actor named Grass that is my "Ground" and i want to randomly spawn "Hills" (the Grass actor) without overlapping? My Grass Actor is 50X50 and theres one in the scene, before the game starts, it spawns itself to the right of itself until it reaches the other end of the world. Is it possible to randomly spawn the 50x50 actor directly on top of one of the actors on the ground and mabye another on top of that to make bigger hills?

Comments

  • PixelMetalPixelMetal Member Posts: 283
    I'd look into using tables.
  • DeadlySeriousMediaDeadlySeriousMedia ArizonaMember Posts: 838
    http://gshelper.com/?p=1439

    This might be a good start. If you figure out and way to use tables to build maps I'd PAY for that template! :)
  • PixelMetalPixelMetal Member Posts: 283
    edited November 2012
    This might be helpful for dealing with tables:


    Using tables to build levels shouldn't be all that difficult, and that video is enough to get started building a full level with tables - maybe use additional columns with more values to define what type of level tile to spawn.

    In my project (which is not using tables) I'm checking a random number value whenever a level background tile is spawned, and triggering the spawning of different level object tile types based on that random value. GS starts with x/y values saved in game attributes and offsets the spawn locations based on the tile size and how many tiles it's spawned so far. That could also be a direction to look into as well.
  • SingleSparqSingleSparq Member Posts: 1,339
    Yes I'm using tables to create my levels in the current game I'm working on. Basically a actor moves across the screen in a grid pattern (reaches one side then starts again, moved down to another line) spawning an actor that matches a table cell number. So the table is set with a variable (if scene=1 use table_lvl1) and a number in the table represents an actor. 1=ground, 2=breaking ground, 3=enemie etc. (if cell value=1, spawn actor)

    This works best with block objects and depending on the size of the scene needs time to 'build' the level so may not be ideal in all situations. For randomization I just build in a random rule to the actor being spawned so the ground actor could actually be 3 different graphics based on the randomize.

    Also set up any actor that you want to reset (hero, enemies etc.) so that they register their x/y positions when they spawn, if they die they move off the screen(not destroy). Your reset button should then set all those actor back to their original positions without rebuilding the level.
  • AppsterDudeAppsterDude Member Posts: 84
    @DeadlySeriousMedia Challenge Accepted! @Everyone Thanks a Million!
  • AppsterDudeAppsterDude Member Posts: 84
    I have a problem, whem i start the level it takes about 5 seconds to spawn...
  • ElfizmElfizm Member Posts: 489
    Yep, that's what happened to me when I used tables to spawn things. It also glitches a bit. So would be interesting to know how you fix this!

    Wish you all the best:)

    Elfizm
  • AppsterDudeAppsterDude Member Posts: 84
    FIXED!!!!!!! I just added a fake loading screen for 5 seconds ( or until the actors spawn) and then destroy the loading screen
  • famekraftsfamekrafts Member, BASIC Posts: 834
    Do not use destroy it will cause lag later in game. Simply take it out of screen using interpolate or constrain attribute.
  • AppsterDudeAppsterDude Member Posts: 84
    edited November 2012
    Thanks for the tip!
  • SingleSparqSingleSparq Member Posts: 1,339
    Yes I should have mentioned the loading screen. Add directions to the game there or include a countdown. Use a load delay to you advantage.
Sign In or Register to comment.