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
This might be a good start. If you figure out and way to use tables to build maps I'd PAY for that template!
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.
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.
Wish you all the best:)
Elfizm