C
CoconutBun
Guest
I've been trying to get a seamlessly looping room working in game maker studio 2. If you ever played Yume Nikki or used RPG Maker its kinda like the room looping in that.
I'm a little new to using multiple views and haven't used surfaces before so I'm running into some trouble.
My current plan is to have 2 views
one that shows the normal game view and other that isn't shown to the player but would show the whole room
Then I turn that second view into a surface and draw that outside of the room on each side and corner
Then I just teleport the player to the other side of the room whenever they reach the edge
This should make the room look as though it never ends and keeps repeating or as though you have walked around a sphere.
My current problem is that I can't get the view[1] to be drawn as a surface, I'm not really sure what I'm doing wrong so I'm just gonna send all the code I have and maybe someone could have a look at it
CREATE EVENT
END STEP EVENT
POST DRAW
ALARM[0]
ROOM START
keep in mind that this code is only drawing a surface under the room. Im gonna add the rest after/if I get that one working
I'm a little new to using multiple views and haven't used surfaces before so I'm running into some trouble.
My current plan is to have 2 views
one that shows the normal game view and other that isn't shown to the player but would show the whole room
Then I turn that second view into a surface and draw that outside of the room on each side and corner
Then I just teleport the player to the other side of the room whenever they reach the edge
This should make the room look as though it never ends and keeps repeating or as though you have walked around a sphere.
My current problem is that I can't get the view[1] to be drawn as a surface, I'm not really sure what I'm doing wrong so I'm just gonna send all the code I have and maybe someone could have a look at it
CREATE EVENT
Code:
//following and movement
follow = -1;
xTo = x;
yTo = y;
moveSpeed = 1;
looping = false;
if (instance_exists(o_Player)) {
follow = o_Player;
}
view_width = 480;
view_height = 270;
window_scale = 2;
window_set_size(view_width * window_scale, view_height * window_scale);
alarm[0] = 1;
surface_y = surface_create(room_width, room_height);
Code:
/// @description
#macro view view_camera[0]
#macro roomView view_camera[1]
camera_set_view_size(view, view_width, view_height);
if (instance_exists(o_RoomSettings)) {
looping = o_RoomSettings.looping
} else {
looping = false;
}
if (instance_exists(follow)) {
xTo = follow.x;
yTo = follow.y;
if (looping = false) {
xTo = min(xTo, room_width - (view_width / 2))
xTo = max(xTo, view_width / 2)
yTo = min(yTo, room_height - (view_height / 2))
yTo = max(yTo, view_height / 2)
}
x += (xTo - x) / moveSpeed
y += (yTo - y) / moveSpeed
camera_set_view_pos(view, x - view_width / 2, y - view_height / 2);
}
if (looping = true) {
//view that shows the whole room
camera_set_view_size(roomView, room_width, room_height);
camera_set_view_pos(roomView, 0, 0);
}
Code:
//Draw the things
if (instance_exists(o_RoomSettings)) {
if (o_RoomSettings.looping = true) {
//create surface of room
if (!surface_exists(surface_y)) {
surface_y = surface_create(camera_get_view_width(roomView), camera_get_view_height(roomView));
}
surface_resize(surface_y, camera_get_view_width(roomView), camera_get_view_height(roomView));
view_surface_id[1] = surface_y;
draw_surface(surface_y, room_width, room_height);
}
}
Code:
window_center();
Code:
view_enabled = true;
view_visible[0] = true;