spritemate
spritemate copied to clipboard
Convert internal sprite data format to binary
The current sprite data uses 0,1,2,3 to represent the sprite colors transparent, single color, mc1 and mc2. This is a typical sprite in multicolor:
[2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0],
[2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0]

This causes all kinds of hacks, e.g. that multicolor changes only every second value and ignores the rest (so that only 12 values instead of 24 are read).
Instead, the file format should properly represent the bit values, like
0 = 00 1 = 01 2 = 10 3 = 11
I see two options to go for:
- Split the bit value into two numbers
0,1,1,1,0,0,1,0,0,1 etc.
The sprite array would remain at 24x21 size, but two numbers would make up for either one multicolor or two singlecolor values.
- Use 0,1,2,3 and split it into bit value
0,2,1,1,3,2,1 etc.
The sprite array would become half the size at 12x21. Another advantage could be that if there's every going to be a version of Spritemate that supports other systems and color ranges, this format would work better.
Which one is the better approach?
Could use your advice here, @nurpax :)
Option 2 seems better, if the rest of your code can handle 24x21 vs 12x21 array sizes.
The choice kind of depends on how your code is structured, but it does kind of feel like say looping over pixels would iterate over whole integer elements (one int == one pixel).
Agreed that should you add say 8 bit colors with a color palette, then option 2 would support that better.