Ookie's wasp algorithm

Hi there! Our game Mount Ookie is all about the wasps. Chasing wasps, picking them up, and throwing them at each other, at obstacles, or into the Ookie's mouth.

Wasps are arriving randomly and land at the Ookie's huge body, in a gradually growing pace. Since each landed wasp drains the Ookie's life, the game also becomes gradually harder.

In the post I want to share how the wasp mechanic work, and how we used it to make the game challenging yet fair, random but with a sense of progress.

Let's start!

Part 1 - WHERE the wasps land?

See the following blue-ish recrangles on the Ookie's body:

ookieemwasp/emarea.PNG

(This is the editor of Godot Game Engine)

The wasps are allowed to land only inside these rectangles. When a wasp is scheduled to arrive, its final location is randomized by the following algorithm:

  1. Calculate the enclosing rectangle of all the areas (that is the tightest rectangle that contains all the small ones). Do this once at the beginning of the game.
  2. Calculate a random point on the rectangle.
  3. If the random point is NOT inside any of the allowed areas, try again (i.e. go back to phase 2)
  4. Snap the point to grid (e.g. so the wasp will be aligned with the platform.

After the wasp final location is picked, then the wasp is created at a random point near the top border of the world.
Then its location is interpolated (i.e. the wasp goes 5% of the remaining path in every frame) until it arrives slowly but surely to its final point; then when it almost at a full stop, the wasp digs into the Ookie's body. You can follow the wasps in this gif to get the hang of it:

walk_small.gif

Alternatives

Initially, the wasps could land on the entire body of the Ookie. This made the game harder because some places were hard to reach without platform below (e.g. to the top and left of the Ookie's head), or were directly below platforms which required a drop-and-catch maneuver which was a little to much to ask from Jam players that make a quick look on every game. So I altered it to (as you can see in the image above) - only directly above platforms or in a jumpable area from platforms.

An alternative to the location-choise algorithm would be to pick a rectangle in random, then pick a location on it. I could make it a weighted random by the size of the square. This would save the recalculation of randomness when you "miss" the allowed area and must try again; but the current algorithm worked well and never caused frames to "get stuck" because of recalculations, so I kept it.
Also, picking a rectangle would not allow me to use overlapping areas, which was the case at start (when I used the entire Ookie's body as allowed area).

Part 2 - WHEN the wasps come?

The wasps arrive at random intervals. After each wasp comes, the time until the next wasp is calculated with the following formula:

rand_range(1, max(5, 8 - game_time*0.03))

And in people's language:

The time is a random value between 1 sec and a number that depends on your progress in the game. At the beginning, the time is between 1 and 8 seconds (meaning an average of 4.5 seconds, a slow pace that is easy to handle). Over time, the wasp pace becomes faster. It's still random, and can still have larger or smaller gap, but the average time gets faster. That is up until time 1:40, then the pace settles on random between 1 and 5 seconds, meaning an average of 3 seconds between wasps, which is quite fast. This pace is kept until the end at 2:30.

See an example timeline (left to right) of when the wasps are spawned:

bee_bar.png

Note that: - The pace is always random, but still has a controlled average that gets faster. This makes a nice distribution, where are some natural "clusters" of wasps that arrive quite close together, and sometimes large gaps between them; - The pace is getting faster very gradually. Because it's still random, it's hard to put a finger on it; but players will still feel the tension built. This feeling is familiar to anyone who had worked at a food stand, and saw the tired dripping of customers gradually becomes a fast flow when lunch time gets closer.

Alternatives

Usually, good defense games have waves. This will allow building of tension, then letting the player have time to gather their strength before the next one.
Maybe Ookie could use some waves in it; however it was intentionally a short game, probably not short enough to split it to several waves. I'd like to see it as a game with waves, but only one of them :) If we were to extend this game further, we would definitely do some waves!

Another thing we could do is not to make the pace grow gradually faster, but make some specific points where we let the player know that the pace "escalates". This could help build the tension; but could also be distracting and hurt the "zen" like feel of the game. Eventually we chose the gradual way because it means that we only have one parameter to balance (the final pace) which was easier to experiment with at the time of the Jam.

Hope you liked this post! Have a go at Mount Ookie and let us know what you think of the wasps behavior and balancing. Enjoy!