Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Finding spawn points

$
0
0

@KuzDeveloper wrote:

Hi,

I am working on a small 2D top down shooter for a game dev competition and was wondering what would be the most effective way to find spawn points for different objects, like the player itself, the enemies and some other game objects on a half-randomly created gameplay area?

The area has borders built by walls, the opposing walls cannot be closer to each other than X and cannot be further than Y, but between these values walls can go upwards, downwards, from left to right and the mix of these.

Collision detection works fine for each object, so you can say something like "if (player.Collide(wall[0] ... ", and vica versa. As the gameplay area is not rectangle shaped, I cannot simply iterate through the upper walls, then the lower walls and check each position between them as doing so would result in a lot of areas checked that are NOT between the walls (so, they can be outside of the gameplay area). And obviously I want to avoid the followings:
- Checking the same place more than once.
- Running into an infinite loop.
- Having loops that are executed longer and longer as more and more objects appear on the level.
- Spawning on the same point every single time, because that point is "always" valid (so enemies would come from the same point every time).

Here a fairly old screenshot of one half-randomly generated level (it is still good to show you my problem):

Is there any general how-to guide on this? Or do any of you have any good thoughts I could use? I can solve this problem somehow, but I fear I will break one of the rules above. :slightly_smiling:

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles