New games every week!
JSE - Compressing the Sprite Blog
15th April 2021
I haven't yet coded the functionality of the Sprite Editor, and instead have chosen to work on its data compression...

-=-=-

The plan is simple.
A plain bog-standard pixel editor with 64 colours to choose from. (with one being transparency)
A grid of 32x32 pixels.

I need to make the data be forum-postable, since the data will be part of the code, not a separate awkward additional file that you have to separately download, then re-upload to the server.
The whole point of the scripting engine is to have easily copy+pasteable code that "just works".

In order to keep the data "pure", I've opted for the following characters.
0 to 9, a to z, A to Z as well as ; and :
These represent our 64 colours.
If each pixel is one of those 64 characters, then we need a (32*32 pixels) 1024 character string to represent a sprite.
.. That's kind of a lot, if I'm honest.

So, yesterday I spent a good hour or so working out how best to compress that down.
The obvious issue is that any resulting data still has to be forum-postable, so only "safe" characters are allowed.
I can't even rely on " and ', since some forums convert those to safer characters before popping them into their SQL database.
£, #, %, ^, &, -, +, <, >, and a few others are also unsafe as far as the web is concerned.
All of those characters work perfectly fine over at SoCoder (although that pound-sign can still be quirky!) but other forums act differently, so I can't always trust that every single one will work universally.

I have to work around this limit, if I want a truly postable results.

... .. So, um.. Yeah..

I started with the string of characters, and added a simple set of rules to allow for repeating characters and such. I'm not 100% sure how well it'll work, since I haven't yet coded the art tool, but I'm pretty hopeful it'll end up a "little" bit smaller than 1024 bytes per sprite.
...
If not, rework, and rethink.
This is definitely one part of the engine that I can't "fix" at a later point, since people would have already drawn a few symbols, and wouldn't like them broken by an update!
I really do have to get this right, first time.

... eek!
Views 129, Upvotes 20  
Daily Blog , Jse
New games every week!
Site credits : Site built from the ground up, in php, using Programmer's Notepad 2, and a very bored Jayenkai.
(c) Jayenkai 2023 and onwards, RSS feed 79

Blog - JSE - Compressing the Sprite - AGameAWeek