2D transforms

0
0
Published 2023-06-12


This game is a little demo of a 2D transformation library I put together.
I chose a simple Asteroids clone because it is a good example of rotation and scaling.
The first tab contains the game. The second tab contains the library.

The library adds commands that affect 2D drawing commands, allowing you to rotate, scale and translate output, similar to the transformation commands in HTML Canvas or the old OpenGL 1.1 matrix stack.

It affects the following Pico-8 drawing commands:

Note: spr and sspr are not affected.

The transformation commands are:

Resets all transformations (to the "identity").
Essentially cancelling all scaling, rotation and translation.
Typically this should be used at the top of _draw()

Translate (move) by (x,y)

Rotate output by a turns (anticlockwise)

Scale output by factor. You can also scale x and y axis independently.

Save the current transformation (to the transformation stack).

Restore the last saved transformation.