Apr 19, 2015

The Infinity Sign (in 8bits)

Want infinity sign movement? Or seemingly random chaotic movement? Or even a simple pendulum or crescent moon pattern?

Building off Konami's Medusa Head code, I got to thinking about how it relates to sinusoidal movement and how to further build off it.

When you apply horizontal motion to the Medusa Head's vertical pattern, you get what passes well enough for a sine wave. We can then say the time it takes to deviate from ystart and return to ystart is 1 period. A cycle contains 2 periods. Thus, in 2 periods the Medusa Head will have traversed all possible y-values in its cycle.

The first logical follow-up from this is that simply incrementing a variable every time a period has completed and checking if it equals 2 would tell us when a cycle has completed. For something like a Möbius strip, you could then reverse the horizontal movement. However, this resulted in a dissatisfying shape similar to two almond-shaped eyes next to each other, with the left and right edges pointy.

Turning the Medusa Head on its side, so to speak, doesn't work either. Applying the same code for the vertical movement to the horizontal movement simply results in a sawing motion. Changing the signs changes the angle of the motion. Still, it feels like a step in the right direction.

It takes 2 periods for the Medusa Head to reach the starting y-position, so I tried doubling the wavelength (doubling the denominator for the horizontal acceleration). This resulted in an awkward but seemingly random mess. It was definitely progress, however.


The problem is the strip spans 2 cycles, not 1. So we just need to double the wavelength once more, and voila!

We can combine the mistake that resulted in the almond-shaped eyes with the strip's code. Reversing the horizontal vector at the end of each vertical cycle will yield only the left or right half of the strip, resulting in movement somewhat like the Interceptors from Starcraft. Reversing both vectors makes it "bounce" back and forth. Reversing only the vertical vector makes it "bounce" at the middle junction, so one bounce up and one bounce down (on the next cycle).

Reversing the vectors after one horizontal cycle changes the behavior. Since a horizontal cycle is longer than a vertical cycle, the strip pattern will reverse after completion. This will result in little hiccups in the motion.

Altering how many periods must pass before reversing a vector can make it difficult for players to predict enemy movement patterns.

Additionally, let's go back to the mistake of using the same acceleration formula for both vectors. The result was a straight, diagonal line. However, if you apply cyclic vector reversal, you can actually create an X-shape by reversing one vector. Reversing both vectors takes us back to the straight line, but this time it traverses half the line each time (that will throw off gamers for sure at least the first time).

For wall-jumpers, the initial horizontal vector will determine which side the wall is when using code that reverses the horizontal vector after any cycle.

Don't be shy. Test out the different combinations

No comments:

Post a Comment

©TheouAegis Productions™. Powered by Blogger.