I made a small demo of a function I have been working on. It is called rspr and can draw sprites with any rotation.
It has the following signature:
rspr(sx,sy,sw,sh,a,dx,dy,dw,dh) -- sx,sy,sw,sh - pos,dimensions in spritesheet -- a - angle -- dx,dy,dw,dh - pos,dimensions on screen
It takes the angle in the same format as sin and cos and draws the sprite rotated around dx,dy.
You can scale the drawn sprite with dw,dh and it can draw sprites of any size.
However, large values for dw and dh cause some serious performance losses, so you should avoid scaling up sprites to unreasonable sizes.
Due to this slowdown, I would really like to have this function implemented natively in pico-8. What do you think, @zep?
Thank you, @freds72, for the suggestion of inlining the function calls. It does speed up the function remarkably.
The scaling is a nice touch - that said you can do a lot faster by inlining most of the function calls.
For scaling, suggest to use sspr for that (e.g write rotated sprite back to sprite sheet and then scale - mucho faster)
See my port of an old Dr Dobbs article: https://www.lexaloffle.com/bbs/?tid=3593 (scroll down the thread)
And @zep said api was complete - if you go this way, a trifill function would be handy...
[Please log in to post a comment]