#21834 - immortalninjak - Mon Jun 07, 2004 10:51 am
Hey all,
My problem is I cant get a background to rotate about a point.
Here is what I am tring to do. In mode 1 i have backgound 2 as a 256x256 rotational background. It is a picture of a rolled up scroll to the right of the screen. What I am tring to do is get it to rotate around the centre of the scroll, so it looks like its spinning.
I am using the RotateBackground from Pern/junkie:
void RotateBackground(Bg* bg, s32 angle,s32 center_x, s32 center_y, FIXED zoom)
{
center_y = (center_y * zoom)>>8;
center_x = (center_x * zoom)>>8;
bg->DX = ((bg->x_scroll<<8)-center_y*(s32)SIN[angle]-center_x*(s32)COS[angle]);
bg->DY = ((bg->y_scroll<<8)-center_y*(s32)COS[angle]+center_x*(s32)SIN[angle]);
bg->PA = ((s32)COS[angle]*zoom)>>8; //cos&sin are LUTs that are .8 fixed numbers
bg->PB = ((s32)SIN[angle]*zoom)>>8; //zoom is also fixed
bg->PC = (-(s32)SIN[angle]*zoom)>>8;
bg->PD = ((s32)COS[angle]*zoom)>>8;
}
The tutorials didnt really explain how this works and I dont really understand it.
The problem I'm having is that when I use this method it shifts the background, ie when I use RotateBackground(&bg2scroll, 0, 10, 10, zoom); it shifts the background 10 to the left and 10 down.
The point I want to rotate about is (188,72)
Any help on this matter would be greatly appreciated thank you.
My problem is I cant get a background to rotate about a point.
Here is what I am tring to do. In mode 1 i have backgound 2 as a 256x256 rotational background. It is a picture of a rolled up scroll to the right of the screen. What I am tring to do is get it to rotate around the centre of the scroll, so it looks like its spinning.
I am using the RotateBackground from Pern/junkie:
void RotateBackground(Bg* bg, s32 angle,s32 center_x, s32 center_y, FIXED zoom)
{
center_y = (center_y * zoom)>>8;
center_x = (center_x * zoom)>>8;
bg->DX = ((bg->x_scroll<<8)-center_y*(s32)SIN[angle]-center_x*(s32)COS[angle]);
bg->DY = ((bg->y_scroll<<8)-center_y*(s32)COS[angle]+center_x*(s32)SIN[angle]);
bg->PA = ((s32)COS[angle]*zoom)>>8; //cos&sin are LUTs that are .8 fixed numbers
bg->PB = ((s32)SIN[angle]*zoom)>>8; //zoom is also fixed
bg->PC = (-(s32)SIN[angle]*zoom)>>8;
bg->PD = ((s32)COS[angle]*zoom)>>8;
}
The tutorials didnt really explain how this works and I dont really understand it.
The problem I'm having is that when I use this method it shifts the background, ie when I use RotateBackground(&bg2scroll, 0, 10, 10, zoom); it shifts the background 10 to the left and 10 down.
The point I want to rotate about is (188,72)
Any help on this matter would be greatly appreciated thank you.