Log In  

Cart #mot_asteriods-0 | 2022-08-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

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:

  • pset
  • line
  • rect/rectfill
  • circ/circfill
  • map

Note: spr and sspr are not affected.

The transformation commands are:

xident()

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

xtran(x,y)

Translate (move) by (x,y)

xrot(a)

Rotate output by a turns (anticlockwise)

xscale(f)

xscale(x,y)

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

xpush()

Save the current transformation (to the transformation stack).

xpop()

Restore the last saved transformation.

P#116309 2022-08-26 04:30 ( Edited 2022-08-26 04:39)

This looks great. Like having Processing available inside the Pico-8.

P#116510 2022-08-29 17:30

You mentioned that SPR and SSPR are not affected. Can you draw rotated sprites with SPR and SSPR using your graphic library, @Mot ?

P#116550 2022-08-30 00:12

@dw817 nope - it's heavily based on tline.

You would have to sacrifice some map memory to layout the sprite and convert the spr/sspr call to a corresponding map call.

P#116566 2022-08-30 07:02

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2022-12-06 10:46:17 | 0.021s | Q:18