A downloadable asset pack for Windows

Buy Now$9.99 USD or more

Room switch - Seamless rooms (found on marketplace and itch.io)

Deactivate and activate areas

Version:

2.3.6

Short desc:

Sometimes you want a giant world or room. But you would like to split it up into small pieces and travel between them without notice the room change. Also providing a YYZ that works in GMS2  with "asset layer". So it do NOT work with the "tile layer" in GMS2. So you can NOT use animated tiles at the edge of rooms.

Video:

Check the video to get a step by step.

Dependencies:

You also need to add the exCamera.gmez that is located in the included files folder and add it as an extension.

(You only need to import the obj_ex_camera)

This extension:

This code module let you travel from one room to the next without notice the room change (ok GM cause a little load room delay):

The view is always in center of the player except on the edges of your big room where the view is limited like an ordinary room.

You can add special objects on the edges that show in all rooms, to hide edges.

If you want to have dynamic stuff near the edges you can set it to zoom in when travel from room to room, this will hide the other room a little.

Add special move coordinates that is recalculated for you.

All in GML and should work on any platform

Lag when travelling from room to room:

GM must load the room you travel to. So if you use alot of objects you will get a small delay. You can mask it by:

  1. Don't use edge objects or tiles near the edge. Just use a tile able background.
  2. Use the zoom feature in scr_room_switch_CREATE(...,TRUE)
  3. Set the player to walk slowly over the edge.  Use if scr_room_switch_IS_ON_EDGE() {make player walk slow} (best result).
  4. Use smaller rooms that GM can load faster.

Code example:

Player object:

You only need to create a 2d array of the rooms you want and call a script in the create event.

MyBigRoom[0,0]=room_left;
MyBigRoom[0,1]=room_right;

and call:

scr_room_switch_CREATE(MyBigRoom,false);

You can also randomize it.

MyBigRoom[0,1]=room_duplicate(choose(rm_1,rm_2,rm_3))
MyBigRoom[0,2]=room_duplicate(choose(rm_1,rm_2,rm_3))

Its important that we use room_duplicate(). Because room switch need that all room ids to be unique. Room_duplicate(rm_1) will create a duplicate of the rm_1 room and give it a new id.

Other examples:

MyBigRoom[0,0]=rm_1
MyBigRoom[0,1]=rm_2

This would just put rm_2 right in rm_1.

MyBigRoom[0,0]=rm_1
MyBigRoom[1,0]=rm_2

This would put rm_2 under rm_1.

Different room sizes:

You can also use different room sizes.

After scr_room_switch_CREATE

Create a 2d array with the room sizes:

MyBigRoom_size[0,0]="3000,2000";
MyBigRoom_size[0,1]="1000,2000";

After scr_room_switch_CREATE call:

scr_room_switch_AFTER_CREATE_EXTRA(MyBigRoom_size);

Just make sure that kolumns got same room width and rows got the same room height Ex:

Edge objects:

You can add special objects that show in same place in all rooms

Just set it to persistent and set the parent to "obj_room_switch_on_edge_parent"

Add it in the room where your player object is. You need to put edge objects near the edge of each room so the player can "see" the room before he gets there. If you place a ordinary object near the edge it wont be visible until the player get to the next room.

Edge objects in each room:

You can also add edge objects in each room. This will make it more easy to place the edge objects.

Just place the edge objects in each room and add one object in the first room of your game:

obj_room_switch_load_edge_objects_in_all_rooms

Done :-)

But that means all rooms must be loaded. Room switch must loop through all rooms in the 2d array. And all create events for all objects in those rooms will run. And you may not want that. So to avoid running a objects create event just add this line first in the create event:

if scr_room_switch_IS_LOADING(true) exit;

This will destroy the object when room switch is loading the edges in the room. If you use the destroy event for something just add this as the first line:

if scr_room_switch_IS_LOADING() exit;

And if the object got a room start event you dont want to run you must add:

if scr_room_switch_IS_LOADING() exit;

Moveable edge objects:

If you use a move to click position object you only need to add x,y array variables. Call init script and add a script before you move.

Create event:

ClickedX[0]=0;
ClickedY[0]=0;
scr_room_switch_RECALC_INIT();
Step event:
scr_room_switch_RECALC_POS_VARIABLE(ClickedX,ClickedY);
// Ex Move script
if x>ClickedX[0] x-=5;
if x<ClickedX[0] x+=5;

Tileset:

You can also use tileset on the edges. Just add the tileset as you usually do and add one object in the first room:

obj_room_switch_enable_tileset_cloning

You can change how much tileset that is cloned to the other rooms. Go to the objects create event and change:

Room_switch_tileset_width=800;

Right now 800 pixels from the edge is shown in the other rooms. If you see tiles disappear when you travel from room to room just increase the value.

Artefact lines

When working with tiles you may see artefact lines on the edges of the tiles. The room switch code will automatically set interpolation to false and change the camera to floor the move position. This will make the camera movement and screen look less smooth but it will fix the problem with the artefacts lines. You can change this in object:

obj_room_switch_create_camera > Create event > AutoFixArtefactLines=true;

Auto deactivate:

When the player walk, the edge objects that is far away is automatically deactivated to save cpu. You can change this or add your own objects in the script:

scr_room_switch_INIT_DEACTIVATE()

Area deactivate/activate:

You can also add area deactivaters/activaters. This is perfect for dungeons. When the player is inside an area all inside it is active. But step out and all will be deactivated. So you can deactivate monster spawner while the player is not present in the room.

Create your own deactivater by createing a new object and give it a sprite then call:

scr_room_switch_ACTIVATE_UNDER_INSTANCE() while player is inside/collide with object. And call:

scr_room_switch_DEACTIVATE_UNDER_INSTANCE() while playes is outside/not colliding the object.

Teleport:

You can also teleport to another room with just one script:

scr_room_switch_TELEPORT(room, x, y)

Go back to menu/exit game:

If you want to exit the game and go back to the menu just call:

scr_room_switch_ROOM_GOTO(room)

This will unload all edges and the player object for you. Room switch will not destroy any of the rooms created with room_duplicate() if you use room switch for a endless runner.

Multiplayer offset calc: When you try use room switch for multiplayer you can now get the offset values from other players with the code:

scr_room_switch_MULTIPLAYER_OFFSET_CALC(your room, other players room);

Then use the return array to recalc the other players pos ex:

var offset=scr_room_switch_MULTIPLAYER_OFFSET_CALC(your room, client.room); client.x=network_x_value+offset[0];
client.y=network_y_value+offset[1];

Endless runner: OBS: There is a bug in room_duplicate that prevents persistent objects (edge objects is persistent) from creating in duplicated rooms. I have send YoYo a bug report about this. You can workaround the problem and use tiles instead of edge objects. You can then place ordinary objects under the tiles.

You can also create a "endless" runner. This is how you ordinary setup room switch:

MyBigRoom[0,0]=rm_y0_x0;
MyBigRoom[1,0]=rm_y1_x0;

This will create a 2x1 room.

But we can use rm_y0_x0 and rm_y0_x1 as templates to setup a endless runner. Simply duplicate the rooms with room_duplicate().

Let setup a 2x2 room with our 2 rooms:

MyBigRoom[0,0]=rm_y0_x0;   MyBigRoom[0,1]=room_duplicate(rm_y0_x0);
MyBigRoom[1,0]=rm_y1_x0;   MyBigRoom[1,1]=room_duplicate(rm_y1_x0);

But you may want a 1x50 room so you can use a for loop:

for (var i=0; i<50; i+=1)
{
    MyBigRoom[0,i]=room_duplicate(choose(rm_monsters,rm_gold,rm_fruit,rm_endless));
}
StatusReleased
CategoryAssets
Rating
Rated 5.0 out of 5 stars
(1 total ratings)
AuthorThe any Key
Made withGameMaker
TagsGameMaker, gamemakerstudio

Purchase

Buy Now$9.99 USD or more

In order to download this asset pack you must purchase it at or above the minimum price of $9.99 USD. You will get access to the following files:

RoomSwitch.gmez 452 kB
RoomSwitch_2_3_4.gmez 453 kB
RoomSwitch_2_3_5.gmez 693 kB
RoomSwitch_2_3_6.gmez 693 kB
RoomSwitch_2_3_6.yyz 1 MB

Download demo

Download
Room Switch Demo.exe 2 MB

Development log