Log In  


Cart #rspr_greygraphics-3 | 2019-05-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

Hi,

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.

9


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...


@greygraphics better but still way too many sin/cos calls!


@freds72 Thank you again for your suggestions. I am also reusing sin/cos values now. I don't think I can get this to run any faster now, without using your sspr trick.


3

Cart #kopemumajo-0 | 2019-05-05 | Code ▽ | Embed ▽ | No License
3

@greygraphics: using DDA "classic" trick, you can get cpu down to 14% (from 22%) :]



[Please log in to post a comment]