Coded Games
Member
Ok so I'm trying to do this fairly complicated split screen effect where I have one view on top of another. The view on top needs to be rotated so that the bottom edge of the view forms a diagonal line across the main view (view0). See whiteboard diagram:
Along with that, I want the content of each view to be the proper orientation, so -y is up in both and +x is right. So I need to rotate the camera itself, and rotate the entire view.
The current way I am doing this is by sending the content of view1 to a surface and drawing the surface in the desired position and rotation.
The issue I am running into is I never seem to get the angles right because everything rotates around a different point. Surfaces rotate around the top left corner so I need to compensate for that when I position the surface and then I'm not even sure what the view itself is rotating around. I hope it is the center as I have the view follow an object.
Here is my code so far:
Create event:
Step Event:
Draw Event:
The issue obviously lies in the aa variable. I keep trying to flip them, add 90, add 180 but every time I get the position of the view right, the angle of the view itself is incorrect, or the entire view is rotated 180. I feel like I must be doing something wrong here. Any help would be really appreciated.
Along with that, I want the content of each view to be the proper orientation, so -y is up in both and +x is right. So I need to rotate the camera itself, and rotate the entire view.
The current way I am doing this is by sending the content of view1 to a surface and drawing the surface in the desired position and rotation.
The issue I am running into is I never seem to get the angles right because everything rotates around a different point. Surfaces rotate around the top left corner so I need to compensate for that when I position the surface and then I'm not even sure what the view itself is rotating around. I hope it is the center as I have the view follow an object.
Here is my code so far:
Create event:
Code:
var ww = camera_get_view_width(view_camera[0]);
var hh = camera_get_view_height(view_camera[0]);
view_camera[1] = camera_create_view(x, y, ww, hh, 0, core, -1, -1, ww, hh);
view_set_visible(1, true);
viewSurface = -1;
Code:
var aa = point_direction(obj_player.x, obj_player.y, core.x, core.y);
camera_set_view_angle(view_camera[1], aa);
Code:
if (view_current == 0) {
if (!surface_exists(viewSurface)) {
viewSurface = surface_create(camera_get_view_width(view_camera[1]), camera_get_view_height(view_camera[1]));
view_surface_id[1] = viewSurface;
}
if (surface_exists(viewSurface)) {
var aa = point_direction(obj_player.x, obj_player.y, core.x, core.y);
var ww = surface_get_width(viewSurface);
var hh = surface_get_height(viewSurface);
var xx = obj_camera.x + lengthdir_x(ww / 2, -aa + 90) + lengthdir_x(hh, -aa);
var yy = obj_camera.y + lengthdir_y(ww / 2, -aa + 90) + lengthdir_y(hh, -aa);
draw_surface_ext(viewSurface, xx, yy, 1, 1, -aa, c_white, 1);
}
}