A downloadable asset pack for Windows

Buy Now$19.00 USD or more


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.

Video:
Check the video to get a step by step.

Dependencies:
You also need to download the awesome exCamera from here:
https://marketplace.yoyogames.com/assets/504/excamera
(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);
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.

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 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:
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.

Endless runner:
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.
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));
}

More information

Published262 days ago
StatusReleased
CategoryAssets
AuthorThe any Key
TagsGameMaker, gamemakerstudio

Purchase

Buy Now$19.00 USD or more

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

RoomSwitch.gmez 449 kB

Download demo

Download
Room Switch Demo.exe (2 MB)

Community