Old School IV – Yet Another Sine Wave Scroller made in Monkey X

Yet another sine wave scroller. Now the wave moves also — just like in the most traditional Amiga demos. 🙂

Below is the video (new version with smoother movement):

The angle for sin function is calculated from the x-coordinate again. 360 is divided by the screen width = 640 pixels, the quotient is 0.5625. The screen position (in pixels) from 0 to 640 – 1 is multiplied by this quotient which makes the sine wave to be positioned to full screen width.

That’s the idea. In the code the starting position can be negative (minus character’s width).

The variable addAngle is added to the screen position for the sin function, which makes the wave move. If the value of addAngle is negative, the wave moves to the other direction.

Below is the code:

Check the other Old School posts for more info and feel free to use this code.