Rotating a sprite?
|
Help! I suck at maths, so the transformation matrix stuff is mostly gibberish to me. :-( Does anybody have some simple code (pref. BASIC) to plot a sprite rotated by a given number of degrees? Thanks. https://www.riscosopen.org/wiki/documentation/show/OS_SpriteOp%2056 |
|
Not sure (read but long time ago). Maybe a bit more with excamples you find here |
|
This’ll get you in a spin…
… the tricky bit it fiddling with the (x%, y%) and (a%, b%) until you get the effect you’re looking for. If you want it to turn on the spot, then you need set x% and y% to be the co-ordinates of the exact centre of the sprite (that’s x% = 40, y% = 40 for the switcher icon). a%, b% just shift the whole animation to put it where you want on the screen. |
|
Thanks Julie, that’s brilliant! I’ve made a tiny modification: REPEAT CLS PROCrotate(rotate%, I%, x%, y%, a%, b%) SYS "OS_SpriteOp", 56 + &100, rom%, "switcher", 0, 0, 8, rotate%, table% WAIT I% += 1 UNTIL FALSE Changed: the
Ah, so that’s the secret, the location is the centre. <tappedy-tap> Yup, x and y at 40 and it rotates in place. I won’t pretend to understand what PROCrotate is doing, but I now have some values and code I can fiddle with to rotate a sprite. That’s exactly what I was looking for. Thank you again! |
|
The CLS doesn’t play nice over VNC, it would be better to unplot the sprite or just erase a smaller area. |