I used this function in the river riddle to h flip sprites.
It only works for 8x8 but you can easily translate for other size or for flip vertical
function fspr(fr,ex,ey) for x=0,7 do sx=8*(fr%16) sy=8*(flr(fr/16)) sspr(sx+7-x,sy,1,8,ex+x,ey) end end
For horizontal flip, sspr() has a flip parameter flag but it does not seem to work. Maybe this will be fixed in v0.1.1.
Benjamin, a minor suggestion for your example: I think you should define sx and sy as local variables in order to avoid creating more costly global variables.
After some research in the forum, I have found this thread describing a direct way to flip a sprite horizontally: https://www.lexaloffle.com/bbs/?tid=1859
In short, there is an undocumented flip parameter to spr:
spr n x y [w h [flip]]
When flip is set to TRUE, it flips the displayed sprite.
-- draw a 8x8 flipped sprite at pixel location (32,32) spr(1,32,32,1,1,true) -- draw a 16x16 flipped sprite at pixel location (32,32) spr(1,32,32,2,2,true)
Strangely, this extra parameter is documented for sspr but has no effect on it. So maybe it is just a documentation issue. Maybe Zep can comment about it.
Anyway, thanks to QuantumFlux42 for this trick.
The sspr() behaviour in 0.1.0 is a bug in the implementation rather than a mistake in the docs.
0.1.1 has working fiip_h and flip_v parameters (for horizontal and vertical flipping), and also allows you to use negative target dimensions with sspr()
[Please log in to post a comment]