Object-spawning in a top-down shooter

My name is Guy Dimor, I’m the sole programmer (and therefore lead coder) for Team Wendigo, currently working on the game Umibozu.

The biggest challenge for me was finding the right way to spawn enemies. I needed them to come into the screen from all sides. My initial idea was for them to spawn randomly on an ellipse just outside of the game screen and then move in a straight line across the screen. A quick google search landed me an algorithm that produces a random point on a circle.
While I wanted an ellipse, I nontheless implamented the algorithm (and adapted it to C#, as it was originally in Java).
I’m somewhat ashamed to admit that it took me too long to figure out how to turn the circle into an ellipse. After a while of struggling with it, I finally realized all I had to do was divide the Y value of the dot by any number larger than 1 to get an ellipse. I made a function out of said algorithm and set the spawn-manager to instantiate enemies using the resulting points as positions. The ellipse can be seen in the featured image.

Once the spawn pattern was created, I need to make the enemies move across the screen. The enemies’ only “AI” is moving forward, so I needed I way to make them point towards the screen when instantiated. I initially had them point towards another random point on the same ellipse. However, too many either did not enter the screen or just barely grazed it. I then decided to have that point towards the player’s position at the time of their creation, which indeed caused all of them to enter the screen. However, this meant that the player had to constantly change position to avoid them, as staying static for long guaranteed taking damage. While that is not a bad feature in and of itself, it does go against the goal of having the player not feel stressed.

My final idea proved more accurate: Have the enemies move towards a random point inside a rectangle slightly smaller than the screen. This meant all enemies entered the screen, but were more evenly spread-out and did not overwhelm the player.

One thought on “Object-spawning in a top-down shooter”

  1. Hello Guy, this is Jesper from Vampire!
    After nine years of development, hopefully this comment would have been worth the wait.

    I think that you managed to properly communicate the process you went through when searching for a solution for the spawning of the enemies in your game. As a programmer myself I always enjoy seeing that the initially thought out solution ended up working in the end, all be it with a few changes.
    I would say that you show a good understanding of the original concept of the game based on the fact that you took the desired aesthetic goal into consideration when designing the behavior of the enemies.
    All in all I would consider this a well written blog post. You clearly communicate what you have been working on as well as bring up the issues you faced while doing so. This blog post provide useful information for future reference and will surely be helpful to anyone trying to find the solution for the same problem.
    Well done!

    Like

Leave a comment