A downloadable asset pack for Windows

Buy Now$9.99 USD or more

Version: v2.3.3

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.

Check the video to get a step by step.

You also need to download the awesome exCamera from here:
(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.
and call:
Different room sizes:
You can also use different room sizes.
After scr_room_switch_CREATE
Create a 2d array with the room sizes:
After scr_room_switch_CREATE call:
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.

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:

Done :-)
But that means all rooms must be loaded. Room witch 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 run 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:
Step event:
// Ex Move script
if x>ClickedX[0] x-=5;
if x<ClickedX[0] x+=5;
You can also use tileset on the edges. Just add the tileset as you usually do and add one object in the first room:
You can change how much tileset that is cloned to the other rooms. Go to the objects create event and change:
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:

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.

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:
This will unload all edges and the player object for you.

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

This will create a 2x1 room.
But we can use rm_y0_x0 and rm_y0_x1 as templates to setup a endless runner.
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)

More information

Published1 year ago
AuthorThe any Key
TagsGameMaker, gamemakerstudio


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

Download demo

Room Switch Demo.exe (2 MB)