Hello,
I am trying to develop a 2d camera for my game and have run into some issues. I'm attempting to use the ALLEGRO_TRANSFORM struct and functions in order to do so, since I need my camera to be able to rotate and zoom. The current code i have is this:
What i wish this to do is scale my coordinate system into a resolution independent system, like openGL does, then allow for rotation, zooming, and translation. Basically, a full-fledged 2d camera.
The translation is working fine, along with the resolution independent scaling. However, both the zooming and the rotation rotate all objects about the origin, which is not the desired result.
Any help would be greatly appreciated.
Try this:
// Update Transforms al_identity_transform(cam); // Reset al_translate_transform(cam, -D_WIDTH/2, -D_HEIGHT/2); // Center the camera al_scale_transform(cam, camZoom*D_HEIGHT, -camZoom*D_HEIGHT); // Scale to range from -1 to 1 al_rotate_transform(cam, camRot); // Rotate al_translate_transform(cam, camX, camY); // Move the camera around al_use_transform(cam); // Use the transform
Thanks for the reply,
I attempted to use it, but it seemed to scale/translate things such that I was unable to find my box that I am drawing using the following command:
Using the order of transformations that I originally posted, this box appears and correctly fills up the entire height of the screen, with even space on each side.
I'm allowing camera interaction thru the following code:
I see where your going with this SiegeLord, tomorrow I'll try to think thru some of the math to figure out how to move the camera to the proper place before rotating/scaling.
Until then, other replies are appreciated, thanks.