Log In  

Hi everyone, i've been working on a pico-8 project to act as a stepping stone to a harder project.

Whilst it's going smoothly, it would be alot easier for my project if I could animate over a table of
sprites rather than the regular spr += 1 thing I see in all the tutorials.

It would allow me to use any sprite i needed from the table without having to organise the table so strictly. Furthermore, because I am using 2x2 sprites I can't as easily loop over sprites using the regular method because just going to the next line of tiles won't really help.

I tried checking some games on splore but I havn't found an answer yet.

Does anyone know a good solution?

P#64314 2019-05-11 03:06

1

I think you might be looking for the sspr() function or maybe the extra options for spr() ? I'm gonna guess you mean 16x16 pixels and not 2 pixels, which means you can just do spr(x,y,dx,dy,2,2) to do double size sprites

Take a look at this thread https://www.lexaloffle.com/bbs/?tid=3287

P#64316 2019-05-11 03:38
1

Here's a quick cart I threw together to show how you can use tables to reference sprites:

Cart #topaduyozo-0 | 2019-05-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Each entry in the table contains the x and y pixel coordinates of the sprite from the spritesheet, the width and height of the sprite image, and the x and y offset to use when drawing the sprite. Having an offset for drawing allows you to remove any blank space between sprites so you should be able to fit more sprites on the spritesheet.

Anyway, if you have a look at the code and how the spritesheet is setup it should be fairly easy to understand.

P#64322 2019-05-11 09:21 ( Edited 2019-05-11 09:22)

Thank you so much @paranoidcactus, this is exactly what I was looking for, you've made my project much easier and I learned a little about tables in the process.

Thanks as well @notb for linking me to that other thread which helped me get a better idea of how to use sspr properly.

P#64323 2019-05-11 11:51

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 09:24:10 | 0.027s | Q:21