So I was running out of sprites and I thought "there must be a decent way around this"
a few hours later I came up with this. This cart is just showing 3 frames of a 128x128 animation - three times the size of the sprite sheet. You can peek at the code to see the relevant function - string_to_sprite() - but if you want to know the pipeline, here's how I did it.
-I just searched for some anime gif at 128x128 to show this off, picked the first one I thought looked neat, opened it in Aseprite.
-I switched over to the pico-8 palette and remapped the image to it
-Then I went to pico-8 and typed the command "export img.png" - this gives you a 128x128 image of the spritesheet.
-Then I went back into Aseprite, opened img.png and copied the first frame of animation to it, and saved.
-Back in pico-8, typed the command "import img.png" - now we have the first frame of animation.
-In the sprite sheet editor view, I copied a 16x4 selection of sprites by holding shift + clicking and dragging, ctrl+c
-I then went into notepad, and pasted the selection. Now, if you do this you'll see a long string, starting with
-I repeated those steps to get 3 more frames.
-So that is what those huge strings at the top of the code are. I couldn't fit the last frame in since I think the character limit is exactly 4 frames large, so to fit the rest of the code in I sacrificed a frame of animation :)
This is kinda dumb, but if you need to swap out tilemaps for extra levels and stuff it might come in handy!
nice and easy trick!
there's the semi-fullscreen icon at the top left. then you can pan & select more. not the the whole frame height though, the UI gets in the way. (an autoscroll or ctrl-a would be nice, zep!). or maybe there's another way I'm not aware of...
you can replace all the if statements by n=("0x"..s)+0
- get your spritesheet back with reload(0,0,0x2000) (you could keep a fourth frame in there)
I think I could be using this for a title or help screen. thanks a lot! :)
btw, the four characters after the tag are the width and height of the data:
width, height = ("0x"..sub(str,1,2))+0, ("0x"..sub(str,3,4))+0
also, if you keep the tags, you can easily copy back and forth between the code and the sprite sheet.
@ianh: sure, but that's an extra uneasy step. the beauty here is the simplicity of a copy/paste.
Hi what's up I needed some sprite compression myself so I made this!
'compress_spsh()' returns the string with the compressed data in it.
You can copy it to the clipboard with 'printh(str,"@clip")'.
Decompress the data to the sprite-sheet with 'decompress_spsh(str)'.
Or decompress it directly to the screen with 'decompress_spsh(str, true)'.
The compression depends a lot on the complexity of the sprite-sheet being compressed. It doesn't like dithering very much.
On this little demo there are 13 different 128x128 frames, but they are not very complex. Still that's better than just 3! ;D
It can definitely be optimized further to get much shorter strings but then the decompressing would also take a lot more time. :/ (if I end up doing it anyway I'll put it here)
Use it however, wherever you want, it's yours! (credit me to make me happy)
enjoy, much love!
Log in to post a comment