Release

Sprite Rotator (Tool)

3

SP4CEBAR 2022-09-02 22:25 (Edited)

This tool makes real-time rotating sprites possible!

It saves many uniquely rotated copies of a sprite character to a file which can be read from ROM by other programs. To view the file in your program, clone the most recent viewer.

How to use:

The viewer loads your rotated sprites via the HYPER_SPRITE(N,X,Y,C,ANGLE) subprogram, it reads metadata from the file

This tool is made exclusively for characters, It doesn't support vector images

The file:

The outdated file V1 starts with 6 bytes of metadata, the current file V3 starts with 8 bytes of metadata, then come all the character files (in 16-byte chunks), that make up larger images, these images take up (16 bytes) * (sprite size+1)^2 Here's more info about the metadata:

File V2 couldn't store negative angles, so there's no viewer for it posted here


SP4CEBAR 2022-09-02 22:28

I just realized that the files are always at their maximum size, that needs to be fixed


SP4CEBAR 2022-09-02 22:34 (Edited)

This program can read it
it always loads the rotated character file from ROM(5)


SP4CEBAR 2022-09-02 22:35

This program was essential to test it


SP4CEBAR 2022-09-02 22:42

I fixed the unlimited file size


SP4CEBAR 2022-09-03 08:45 (Edited)

Update for the viewer: now it shows the full range of angles, not just until 90 degrees


was8bit 2022-09-03 17:16

Very cool :)


SP4CEBAR 2022-09-03 19:32

Thanks! I got inspired when I revisited one of those online games I used to play when I was a kid: potty racers 3, and I realized that those games are really quite simple to make, you only need motion physics and... rotating sprites


SP4CEBAR 2022-09-03 19:33

I found another problem: it loads characters from local ROM, it's so easy to confuse local ROM with the disk


SP4CEBAR 2022-09-03 19:40

It's fixed!


was8bit 2022-09-04 02:52

:)


SP4CEBAR 2022-09-04 13:32

Big update: file V2 is here, and it's incompatible with file V1, progress bars and displays are added


SP4CEBAR 2022-09-04 14:31

Mandatory bugfix, I switched to pokew so that I can store negative angles, this is file V3


SP4CEBAR 2022-09-04 14:44 (Edited)

Here's the new reader, it reads file V3, and it should be copied into the program that wants to use the rotated characters
Flaws:
- character memory usage of the empty space around a character
- 370 degrees is equal to 10 degrees (but instead the file writer has already set the limits and it gets really complicated)


SP4CEBAR 2022-09-05 12:01 (Edited)

I made a new file viewer:


SP4CEBAR 2022-09-13 08:01

Update
- artifacts are fixed! however, the edges may look a little rough


nathanielbabiak 2022-11-15 03:04 (Edited)

Hey did you know you can eliminate that grid of black dots in the rotated raster? I mentioned how here and, for an example implemented it here. In that upload there's a subprogram, BMP_ROT, and it's got this line in it:

BMP2(PX,PY)=BMP1(NEWX,NEWY)

What your upload here does is essentially this (using the notation from my upload):

BMP2(NEWX,NEWY)=BMP1(PX,PY)

Note that the changes to those indices will also change the direction of rotation.

Anyway, if you switch things around a bit, you can get rid of that black grid. :-)


SP4CEBAR 2022-11-15 14:01 (Edited)

Cool, so if I understand it correctly: my method loops through the input image's pixels, and your method loops through the output image's pixels

A while ago I closely analyzed the gaps and the rounding in of these pixel rotations in Processing and I found that indeed all points miss the rotated square, I tried to find something to predict where the gaps are going to form, the method I eventually used to get rid of the gaps was to add each pixel twice (with offset x+1), which is a terrible solution because it makes all edges rough


nathanielbabiak 2022-11-16 01:29 (Edited)

Exactly.

I'm impressed by the way - you and I saw the same issue and came to pretty similar conclusions. My initial response in that thread I linked was to over-process the pixels. (Although that method is a bit overkill!) Yours is also to over-process the pixels - with a much faster method.

It was only a day or so later when I realized the loop-through output (rather than loop-through input) would solve the same problem, and be faster too.


SP4CEBAR 2022-11-16 21:09 (Edited)

Matrixes work better on vector images, especially If you're scaling the image up
in that case, you can turn a pixel image into a vector image, and flood-fill the surface, or in this case a flood fill may not be needed, the rotated cube surface could be predicted


Log in to reply.