Log In  

Sorta like when using arrows in sprite editor. Because I've came up with a nice waterfall sprite for my secondary project (Contra demake), but it requires me to be able to move it - in theory I could make it so waterfall consists of multiple frames, each slightly moved downwards, but I don't want to waste sprite space like that.

P#14195 2015-09-15 12:00 ( Edited 2015-09-16 17:05)

You could put two copies of it in the spritesheet, one above the other, and then just render successive -1 increments to the sy parameter of an sspr() call to move the tile window up (and so effectively cycle the animation down) by one pixel each time. Once you get all the way to the top sprite, jump back down 8 pixels, repeat.

P#14197 2015-09-15 12:08 ( Edited 2015-09-15 16:08)

No, you don't understand. I mean this:

I want to do that at runtime.

P#14199 2015-09-15 12:19 ( Edited 2015-09-15 16:21)

And I am describing a workaround that uses only 2 sprites instead of 8 sprites, and a little bit if runtime code, to do functionally that.

P#14203 2015-09-15 12:50 ( Edited 2015-09-15 16:50)

Like joshmillard said, put two of them on top of each other, and then do this:

 t += 1
 if (t >7) t = 0
 sspr (0,8-t,8,8,0,0,8,8)

You get away with 33 tokens, but use 2 sprite slots.

If you really want to use only one sprite, then making two sspr calls, one drawing the top, the other the bottom, and changing this spot could work too, but use a lot more tokens.

P#14205 2015-09-15 13:00 ( Edited 2015-09-15 17:00)

This should do the trick if you value one tile of sprite memory over some computational cost:

t += 1
if t > 7 then t = 0 end
sspr(sx, sy + 8 - t, 8, 8, dx, dy)
sspr(sx, sy, 8, 8 - t, dx, dy + t)

...or this alternatively if you want to run it on a global clock, allowing it to be easily wrapped into it's own function:

--assuming t is defined and iterated somewhere else
local clock = t%8
sspr(sx, sy + 8 - clock, 8, 8, dx, dy)
sspr(sx, sy, 8, 8 - clock, dx, dy + clock)
P#14207 2015-09-15 15:47 ( Edited 2015-09-15 19:59)

I've done this by just editing the spritesheet with SGET and SSET.

P#14215 2015-09-15 20:59 ( Edited 2015-09-16 00:59)

Another option is to use the reload() function to overwrite the sprite memory with a shifted copy from the cart memory.

This would use slightly less code than SGET/SSET since you can copy an entire row at once. You could animate multiple sprites at the same time too. Just line them up horizontally in the sprite sheet and shift them all at the same time.

P#14251 2015-09-16 13:05 ( Edited 2015-09-16 17:05)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-03-20 13:15:45 | 0.006s | Q:18