Sunday, June 4, 2023

Animations Loaded from Optimised App Assets Displaying Correctly

What a mouthful that title is. But.... it's exactly what it means. I managed to get a bit of time this weekend to work on my code and finally got the next bits working as I'd wanted them to. 

I previously managed to get my editor outputting optimised bitmaps to a folder location, but now have the app picking those images up, along with metadata about how to render them properly with their optimisations on start-up, finally slice up the resource in the app into frames, then render it all to the map properly.

I totally get that I'm getting deep into the weeds here in terms of technical stuff, but I've been working towards this for a damned good few nights now, so seeing it all render properly as it would be is finally a delightful. Here's what it does in detail if you're interested.

Lets use the image above as an example. The torch has 6 frames in the animation. It's rendering to a 64x64 space. If I was to use a 64x64 bitmap sized correctly, this would take up 96kb of RAM in the app to store that animation. I had already worked out a way to keep certain tiles (not animations, but I could have done so) in a smaller native resolution, then scale them up. So, lets say that I stored the torch animation in a 32x32 pixel format with 6 frames of animation. That's 24kb of RAM. Much better - that's why resolution is so crazy important. However. With the extra optimisations I've managed to add to trim unused pixels from top, bottom, left and right, then the extra code in the app to make sense of it all, the full animation only takes 5.5kb of RAM. That's a huge saving and why I've been working towards this for a good few coding sessions now.

This will now happen automatically for every animation I create with basically next to no effort on my part to do all that other than selecting what frames from the original asset spritesheet go into the animation.

No comments:

Post a Comment

Inventory, Loot and User Interface

So, I've been basically doing another side-quest with the code over the past few evenings and Saturday, writing up all the code for the ...