Psyflex is an Independent Game Development Studio. Founded October 2014, based on Athens, Greece. Regardless of our recent entrance in the indie scene, we collectively possess more than two decades of industry experience.

Post tutorial Report RSS Behind the scenes: Random, but not quite!

This article outlines our spawn strategy we used "in Cyclos: Revolution".

Posted by on - Basic Client Side Coding

Ever wondered how do they spawn enemies in games, in such a way that the spawn positions make sense and are somehow unpredictable?

“Simple”, you might say, “just use random numbers”. Well, this kinda works, at least most of the times. The problem lies within that 1% of times when you happen to spawn a monster on top of another or at a position that doesn’t make any sense. Depending on the game specifics there might also be other problems, like spawning large groups too close together, leaving most of the screen empty, spawning off-screen et cetera.

Here is our solution to the problem. We call it the “Awareness Sensor”. It is a module that examines the play-field and regularly fills a queue with spawn point suggestions. In the picture below you can see:

  1. on-screen spawn positions (blue)
  2. off-screen (white)
  3. off-playfield (black)
  4. possible horizontal and vertical line spawn positions (purple)
  5. already occupied positions (red) and
  6. neighbouring to occupied (green) positions

A snapshot of the Awareness Sensor in action.

A snapshot of the Awareness Sensor in action.


To ameliorate the fact that this is a regular grid, we add a random displacement within the boundaries of the cell.

A cell spawning a Reactor

A cell spawning a Reactor


Even though this grid approach is trivial in theory, making it run fast was rather complicated. We’re not going to bore you with the details. Just note that not all possible positions are displayed. The sensor is only working when more spawn positions are required, being gentle to your mobile’s battery so you can play more!

Stay tuned for more news and behind the scenes stuff!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: