Log In  
Follow
preppie
[ :: Read More :: ]

I'm sure this must have been requested before but I'll post this anyway.

Please could you give a second colour to the right click in the sprite editor. This would make deleting mistaken pixels so much easier.

A second tile in right click for the map editor would be great too.

Thanks.

P#121223 2022-11-23 07:28

[ :: Read More :: ]

I'm new to PICO-8 so please forgive me if something simlar has already been posted (I searched and couldn't find what I wanted)

I wanted to be able to draw on the map and then have some of those map tiles animated.

The following code will animate a map tile by copying memory from a number of sprites to a main sprite which you draw on the map.

The main sprite must be immediatly followed by the animation frames, and (for simplicity of code) all frames must be on the same row of the sprite sheet. This gives a max of 15 frames of animation in a row, with 1 main sprite.

Animation is by rotation (frame 1,2,3,4,1,2,3,4 etc) if you want ping-pong (1,2,3,4,3,2,1,2,3,4 etc) you'll need to tweak the code.

Please forgive my code, I've never used LUA before - I'm used to Atari BASIC and 6502 Assembler. I'm sure this can be done better, so if someone more experianced with LUA would like to re-write it then that would be great.

Cart #zorubegoh-0 | 2022-11-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

There are 5 paramters of map_animator{a,b,c,d,e}

a=sprite number to animate
b=number of frames
c=current frame (set this to 1, the function will change it)
d=speed (1= every frame, 2=every 2 frames etc. if you set this to 0 the animation will stop)
e=speed counter (set it to 0, function will change it)

if you want multiple tiles to animate then add an additional group of 5 parameters

You'll need to call it once for every tile that animates, so if you have 2 tiles you do:

map_animate(1)
map_animate(2)

Hope this is useful for someone.

edit. If you don't want to use up all your sprite sheet with frames you could store the animation frames data in a table and copy it to the main tile and just have your main tile in the sprite sheet. If I'm correct in the way that integers are stored then it would take 4 tokens per frame.

edit2: I just realised that strings cost same tokens regardless of how big they are, so you could use a single string to store as many frames as you want for minimal tokens.

P#121099 2022-11-21 09:14 ( Edited 2022-11-21 11:49)

Follow Lexaloffle:          
Generated 2024-04-19 11:36:05 | 0.099s | Q:10