V
voltorben
Guest
I’m building a game where the player should be able to rotate the camera and the gravity will shift to the new orientation.
But I’m having some problems with my rotated camera.
My room has a viewport of 320x240 px (20x15 tiles)
Viewports are enabled.
My camera object in the room is setup like this:
o_camera, create:
This camera renders my room correctly and follows the player, and stops the camera at the edges of the room.
However, when I change the code to use a rotated camera instead, like this:
o_camera, create:
The camera also renders the room correctly and follows the player somewhat, but not all the way to the edge of the room: The camera stops 2.5 tiles from the original E and W edges of the room (and the player will disappear behind the camera), and the camera shows an extra 2.5 tiles on the original N and S edges (of the room background).
As you might have noticed the number 2.5 is not random - it’s half the difference of the w and h tiles: (20-15)/2 = 2.5
What am I doing wrong here? Have I misunderstood how I should be using the camera/view dimensions?
Or the rotation?
I feel like this should be very simple. I also have a half working solution with a matrix_build_lookat and matrix_build_projection_ortho camera, but the matrices are giving me a headache, especially how I’d go about interpolating the xup and yup of matrix_build_lookat when rotating the camera (so if you have advice for that, I’m all ears).
Any help or ideas appreciated
But I’m having some problems with my rotated camera.
My room has a viewport of 320x240 px (20x15 tiles)
Viewports are enabled.
My camera object in the room is setup like this:
o_camera, create:
Code:
camera = camera_create_view(0, 0, 320, 240, 0, o_player, 3, 3, 120, 120);
view_camera[0] = camera;
However, when I change the code to use a rotated camera instead, like this:
o_camera, create:
Code:
camera = camera_create_view(0, 0, 320, 240, 90, o_player, 3, 3, 120, 120);
view_camera[0] = camera;
As you might have noticed the number 2.5 is not random - it’s half the difference of the w and h tiles: (20-15)/2 = 2.5
What am I doing wrong here? Have I misunderstood how I should be using the camera/view dimensions?
Or the rotation?
I feel like this should be very simple. I also have a half working solution with a matrix_build_lookat and matrix_build_projection_ortho camera, but the matrices are giving me a headache, especially how I’d go about interpolating the xup and yup of matrix_build_lookat when rotating the camera (so if you have advice for that, I’m all ears).
Any help or ideas appreciated