[Gambas-user] the math behind full screen rotation
Kevin Fishburne
kevinfishburne at ...1887...
Tue Mar 22 04:28:14 CET 2011
Just when I thought I could see the sun I was cast down again into
darkness. I've been working on this problem for several days with
limited success.
I'm trying to implement full screen rotation in an overhead-perspective
game. The angle of the screen is locked to the angle of the player. If
the player turns then the screen also turns, meaning the player is
always facing "up". Here is an example of exactly what I'm trying to do:
http://www.youtube.com/watch?v=lX_bhygaSy0
These are the variables I'm working with:
orientation ' Player/camera's angle in degrees (Rad(orientation)).
bworkspace ' Image buffer containing the original non-rotated background.
brotated ' Image buffer containing the new rotated bworkspace.
cx ' Camera's x coordinate in bworkspace.
cy ' Camera's y coordinate in bworkspace.
brotated is larger than bworkspace because the rotation function doesn't
crop the rotated image:
http://www.eightvirtues.com/sanctimonia/images/bworkspace.png (512x512)
http://www.eightvirtues.com/sanctimonia/images/brotated.png(725x726)
How do I convert the camera coordinates (cx, cy) in bworkspace to the
equivalent coordinates in brotated? Essentially I need bworkspace to be
rotated around (cx,cy), but the rotate function only rotates about the
center of the image. Because of this I think I need some combination of
rotating (cx,cy) about some point and offseting it as well. Reading my
own email it sounds simple, but I've tried so many things that I can't
believe I haven't solved the problem through sheer luck.
--
Kevin Fishburne
Eight Virtues
www:http://sales.eightvirtues.com
e-mail:sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list