#46920 - connor9 - Sat Jul 02, 2005 2:33 am
I'm having a bit of trouble with rotation backgrounds. I want to be able to rotate a background about the center point of the screen as in this picture:
[Images not permitted - Click here to view it]
After you've rotated say 45 degrees, if you press up or down I want background to move up and down relative to the screen as opposed to relative to it's own position. As in number two in the following figure.
[Images not permitted - Click here to view it]
From reading the old cearn tutorials I can only seem to get the behavoir shown in number 1 of the second picture. When you press up or down it moves up and down relative to the background. I.e if you've rotated 45 degrees. Down will move it in a 45 degree angle line.
Any help would be much appreciated.
Update: Here's the code for it:
This will rotate about the left corner of the screen(bad), but up and down are relative to the screen not the background(good!)
This will rotate about the center of the screen(good!), but up and down are relative to the background not the screen (bad)
[Images not permitted - Click here to view it]
After you've rotated say 45 degrees, if you press up or down I want background to move up and down relative to the screen as opposed to relative to it's own position. As in number two in the following figure.
[Images not permitted - Click here to view it]
From reading the old cearn tutorials I can only seem to get the behavoir shown in number 1 of the second picture. When you press up or down it moves up and down relative to the background. I.e if you've rotated 45 degrees. Down will move it in a 45 degree angle line.
Any help would be much appreciated.
Update: Here's the code for it:
Code: |
s16 s = SIN[angle & 0x1FF] >> 4; s16 c = COS[angle & 0x1FF] >> 4; (scaleX,Y are alwats 1 << 8) |
This will rotate about the left corner of the screen(bad), but up and down are relative to the screen not the background(good!)
Code: |
s16 tX = scrollX<<8; s16 tY = scrollY<<8; s16 tcx = (c*scrollX - s*scrollY); s16 tcy = (s*scrollX + c*scrollY ); BG3_XDX = ( c * scaleX ) >> 8; BG3_XDY = (-s * scaleX ) >> 8; BG3_YDX = ( s * scaleY ) >> 8; BG3_YDY = ( c * scaleY ) >> 8; BG3_CX = tcx - rcX * (c - s); BG3_CY = tcy - rcY * (s + c); |
This will rotate about the center of the screen(good!), but up and down are relative to the background not the screen (bad)
Code: |
s16 tX = scrollX<<8; s16 tY = scrollY<<8; s16 tcx = tX; s16 tcy = tY; BG3_XDX = ( c * scaleX ) >> 8; BG3_XDY = (-s * scaleX ) >> 8; BG3_YDX = ( s * scaleY ) >> 8; BG3_YDY = ( c * scaleY ) >> 8; BG3_CX = tcx - rcX * (c - s); BG3_CY = tcy - rcY * (s + c); |