Scaling doesn't work with transformation.
When I use the following code:
Why after scaling the character is not in the middle of the screen? instead, he's pushed a little to the left and up. and so the camera moves before the character is on the middle of the screen.
Why after scaling the character is not in the middle of the screen? instead, he's pushed a little to the left and up.
Well, you just moved the translation transform down and right, so of course the player would be moved left and up, unless you apply another transform to the player (with the opposite values). What exactly were you expecting?
and so the camera moves before the character is on the middle of the screen.
We can't really help you much there without seeing your full game loop.
Thread #615756. Printed from Allegro.cc
ok, alright... when using transforms and applying scale and rotation, you now have to consider the the origin of your camera. With the method I used in that thread from earlier, the camera's origin is at the upper left corner of the screen. This is fine and dandy for that, but when you scale or rotate the camera, it will scale relative to the top left corner of the screen.
So try this:
That new line of code I added will move the cameraPosition origin so that it now represents the center of the screen.
For fun, you can easily see the camera scaling to and from the origin like this: