Hey fellas!
I am doing a sort of a scrolling shooter. But I am not designing the levels, I am actually generating them off the screen and letting the view come to them. After they exit view, they get destroyed. So all in all, I have very few active objects in the game at any given moment - they get generated, get seen and then get destroyed.
It is a fun concept to work on, however, very quickly you realize that you have to come up with the mechanism of making sure the objects won't overlap when generating, since it doesn't look good. There are several ideas I came up with, namely:
0. Collision events.
A straightforward solution, but very tiresome. The game is in the beginning stages, and I already have about 15 different enemies. About 20 more are planned. Creating collision events for each one of them dealing with collisions with each of the other is unrealistic and maybe even technically impossible - I am not sure gE would handle so much events in a project. Obviously, this is a bad solution.
1. Using CollisionFree
Good solution, but the downside is that it will not differentiate the collider object. With some objects it is ok to overlap. Also, I wonder how CPU intensive is CollisionFree.
2. Using a variable.
It is possible to create a system of flags and somehow mark the used rows. For instance, I have width 480, say an object of 30 by height was generated at 130. So rows 130-160 are now busy and they can be busy, say, until the object collides with view. Or when the view moves the amount which is equal to the width of the object.
This sounds fine, the downside here is that it can be a complex system. I have many objects in the game, many different type of enemies and bases and creating so many variables and various collision events can become a nightmare.
3. Actually make generation along the y axis semi-random, meaning fixed "corridors" for objects. It won't solve the problem fully, but it would at least allow to minimize it. The downside is obviously the feel of the levels might not be as realistic and spontaneous and plus it does not solve the problem fully anyway.
4. Get the x, y of the latest object and somehow work from there. Pretty simple idea, came up with it after I wrote this post and came back to edit. Not yet sure, though, exactly how to use this.
It is always good, however, to get some advice. Maybe I am missing something simple? Any ideas?