Cheating Newton's Laws

by Tom on

An important feature of Roche Fusion is that enemies with the same colour follow similar behaviour. Each of the colours has a certain theme applied to it: the red enemies follow the so-called "Australia" team, modelled after different dangerous animals - snakes that only want a bit of love, and spitting spiders. Blue enemies - separated in two subgroups - are a bit more boring: the either fly in straight lines shooting pews, or follow arcs and fire lasers.

These themes are very important in a game that is procedurally generated like Roche Fusion. It is important that the player can recognise behaviour and know how to defend themselves against it. Even when variations in behaviour are introduced later in the game, the general drift of the enemies does not change, making it easy to anticipate on what they are doing.

The behaviour themes are extended into the boss fights. When a huge blue monstrosity approaches you, you can count on a whole lot of lasers (or pews, depending on the exact tint of blue) coming your way soon, and it doesn't take a lot of imagination to recognise the behaviour of the snake boss.

In the content update - coming soon to Roche Fusion for free - a new epic boss will be introduced. The design of this purple epic boss was quite the challenge. The theme of the purple enemies consists of having a very militaristic nature (the formations) and being very physical in attacking the player. This behaviour can also be clearly spotted in the purple mini-boss.


Adding a militaristic nature to a boss fight isn't difficult, since we can add a lot of support enemies. The epic boss is in fact the general of a large army of purple enemies, and - discontent with how his soldiers are not doing much harm to you - comes to fight you itself. It was however obvious that to keep the purple enemy theme going, we had to give the boss some form of physical attack.

This is where we ran into a problem: epic bosses are big... very big. We can't just take the dashing of the mini-boss and fit it to the epic boss. It would not look right due to its proportions, but furthermore, it would also not really work well for the gameplay, since it would become very difficult to dodge the boss.

The solution seems so obvious: just make the boss slower. And in fact, that is exactly what we did. We still had to give the boss the illusion of speed though, and that is where a new graphical trick comes in.

The trick is inspired by something that can be seen in (old) cartoons. Look at for example the following notorious fast runner:


This example clearly shows a well-known technique for inducing speed: after images. Apparently the character moves so fast that we can see it multiple times. While mostly a stylistic effect, we felt that the effect would fit very well within Roche Fusion, so we went to work:

The implementation of the effect is quite simple. When a dash like the one shown above is initiated, we start recording the position of the enemy every 0.1 second, so we can replay the movement of the boss by using the keyframes to interpolate the boss position. We could also have recorded the position every frame, but since Roche Fusion supports playing the game without an FPS cap, the amount of memory usage would be theoretically unbounded as well. The chosen time step turns out to give very smooth results by interpolating the actual positions between the steps.

Technical note 1: in this particular instance the boss always moves in a straight line, which makes a time step of 0.1 second sufficient. For movements that contain curves however, there would be very clear points in which the movement is not smooth. A solution would be to use smaller time steps, but this leads to a lot of precision on straight sections of the path. To solve this issue in Roche Fusion we use an adaptive sampling method that stores a point after a predefined time step, or if we detect that the angle between the current movement vector and the difference between the last two recorded points becomes larger than a given threshold.

To determine where the after images should be drawn, we replay the movement of the boss with a very small delay. The after image itself is achieved by redrawing the entire enemy with a higher so-called holoness factor (the replacement for fading using in Roche Fusion, for example when (re)spawning). The after images fade out when they are close to their original, to give the effect on overall slick look.

Technical note 2: in theory we could have simulated the movement of the phantoms separately in an identical manner as the original. The small discrepancies that would come from float rounding would not be noticeable, but if the boss movement would be influenced by external factors (e.g. pushing), the movement of the images would diverge, unless a list of external influences would be stored, which is impractical. Further, storing the position makes the code extendible to arbitrary movement behaviours.

The result is a very interesting looking illusion of speed, while giving us the freedom to tweak the actual speed of the boss to fit the gameplay. You will be able to take your chances against this boss very soon in the free content update coming to Roche Fusion. I am looking forward to hear what you think of it!