bgRotate() Rotate from center of graphic

Post Reply
tomjkear
Posts: 5
Joined: Wed Sep 30, 2009 1:03 pm

bgRotate() Rotate from center of graphic

Post by tomjkear » Wed Sep 30, 2009 1:15 pm

Hi,

I am new to development for the NDS but I am familiar with C++ and common programming concepts. Basically I am using grit to load a 16 bit .png image in as a background. I am then trying to make the background rotate in either direction.

I have found the function bgRotate() which I can use to rotate the background in an anti-clockwise direction around the top left corner. Can anyone tell me how I can rotate the graphic around its center point rather than the top left corner? I have already attempted to use the bgSetCenter() function but instead of keeping the background at its original coodinates and only moving the center point for the rotation, the image is being moved also.

I have Googled my socks off but cannot find anything that makes it any clearer to me. Any help would be much appreciated.

Cheers,
Tom

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: bgRotate() Rotate from center of graphic

Post by Sylus101 » Wed Sep 30, 2009 6:21 pm

The example under (your devkitpro install dir)\examples\nds\Graphics\Backgrounds\rotation\

Should be of great help.
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: bgRotate() Rotate from center of graphic

Post by vuurrobin » Wed Sep 30, 2009 6:25 pm

AFAIK, the only way to rotate a background with the center as its rotation point is to rotate it from the top-left, and then move the background position to the correct place using some calculations. which is what the background api is doing. if it doesn't work then I think there is a bug in the calculations.

could you describe what is going wrong some more? does the background still rotate, where does its position move to ect. this might help finding the bug.


edit: sylus beats me to it <.< . check the examples to see if that works.

tomjkear
Posts: 5
Joined: Wed Sep 30, 2009 1:03 pm

Re: bgRotate() Rotate from center of graphic

Post by tomjkear » Wed Sep 30, 2009 6:50 pm

Sylus101 wrote:The example under (your devkitpro install dir)\examples\nds\Graphics\Backgrounds\rotation\

Should be of great help.
Brilliant, I will take a look right away. Thanks for pointing that one out ;)
vuurrobin wrote:AFAIK, the only way to rotate a background with the center as its rotation point is to rotate it from the top-left, and then move the background position to the correct place using some calculations. which is what the background api is doing. if it doesn't work then I think there is a bug in the calculations.

could you describe what is going wrong some more? does the background still rotate, where does its position move to ect. this might help finding the bug.
The background rotates perfectly, but only around the top left corner. Moving the rotation centre actually moves the top left corner of the background. It therefore continues to rotate around the top left corner but with said corner positioned where the rotation centre was set to.

tomjkear
Posts: 5
Joined: Wed Sep 30, 2009 1:03 pm

Re: bgRotate() Rotate from center of graphic

Post by tomjkear » Wed Sep 30, 2009 7:00 pm

Sylus101 wrote:The example under (your devkitpro install dir)\examples\nds\Graphics\Backgrounds\rotation\

Should be of great help.
Dude, this example is EXACTLY what I was after. You legend! :D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests