Old School II — Sine scroller made in Monkey X

I made today a scrolling version of the Old School Monkey X demo.

What’s new in this one is that it has sine wave text scrolling like in the good old Amiga demos in the late 80s. The font.png and font.dat are again made with my Font 2 PNG program.

See the video:

In the actuall program the movement is smooth.

This one has a very simple implementation of the sine scrolling.

The idea of the algorithm goes like this in short:

  • determine the width w of the first character to be drawn

  • draw a string that’s length in pixels is 640 + w starting from string index of the first character to be drawn

  • draw the determined string to position x (starting value of x is 0)

  • decrease x by 2 (speed)

  • when x <= w add the offset of the first character to drawn by 1 and set x = 0

These steps are repeated with checking if the end of the string is reached.

Mojo2 clips the graphics that are drawn out side the visible area.

The code presented here needs the string start and end with spaces so that always a string from chrStartOffset to chrEndOffset can be built and drawn to screen.

Not the best way to do the sine scrolling for each letter, but very simple. 🙂

Below is the Monkey X code:

Feel free to use the code.