Room Change ideas?

Halph-Price

Member
So I can't seem to find a great tutorial on room changes, like if you were to do a Zelda style map with multiple maps not in order, do I have to create an individual object for each doorway on each map to move the player from room to room?

If yeah, I'll just get on it, but it feels like there should be an easier way..

I understand all the basics, just havn't found many options let alone customizable options beyond a series of objects.

Like, I guess I could still just come up with a bunch of interchangeable objects with arrays that just correspond to each room to each other room and position... Seems like a lot of work, and just wondering if I should just learned C# instead....
 

pixeltroid

Member
STEP 1. make an object, call it door_obj. Then in its create event add this code:

//initialize the door
new_x = 0;
new_y = 0;
new_room = noone
STEP 2. in your player object create a collison event with the door object you created and add this code

if (room_exists(other.new_room)) {
room_goto(other.new_room);
x = other.new_x;
y= other.new_y;

spawnx = other.new_x;
spawny = other.new_y;

}
STEP 3. ,, Lets say your room is called room 1 and you want to go to room 2). place the door in your room 1 and in the room editor, right click on it and select creation code and paste this code

new_room = room2;
new_x = 160
new_y = 464

spawnx = other.new_x;
spawny = other.new_y;
This should send your player to room 2 at the coordinates given as new_x and new_y.
Note that the values for new_x and new_y in the code are just examples. You should adjusted them as per the layout of the room you want to go to.
 

Halph-Price

Member
well u dont understand all the basics. try variables
Using arrays to replace the variables based on which room they're in, I meant. But thanks for the help, I'll work on it.

STEP 1. make an object, call it door_obj. Then in its create event add this code:



STEP 2. in your player object create a collison event with the door object you created and add this code



STEP 3. ,, Lets say your room is called room 1 and you want to go to room 2). place the door in your room 1 and in the room editor, right click on it and select creation code and paste this code



This should send your player to room 2 at the coordinates given as new_x and new_y.
Note that the values for new_x and new_y in the code are just examples. You should adjusted them as per the layout of the room you want to go to.
Any idea on how to change the variables, or I just have to make a unique door object for each entrance and exit of each room for the entire game. I figure what you're saying is obviously what's going to happen, just wondering if there was any other options.
 

pixeltroid

Member
Any idea on how to change the variables,or I just have to make a unique door object for each entrance and exit of each room for the entire game. I figure what you're saying is obviously what's going to happen, just wondering if there was any other options.
You don't have to make a new door object for each entrance. You can reuse the same door object throughout the game.If you want a different looking door, just make a copy of the door object and assign a new sprite.

You can change variables in the the room editor. Just place the door where I want it to be and specify the co-ordinates for where the player will appear in the next room.

So if the door in room 1 leads to room 2, just figure out where the player should appear in the next room and punch in the x,y coordinates. Also specify that its room 2.

This way you can add doors to all your rooms so your player can enter and exit the room as and when he likes. But just make sure that the x,y coordinates where player appears is not directly on another door object, or it will cause an error.

BTW I'm not really a programmer. I'm just using code that someone here gave me a long time ago. Its simple but it works fine for me.
 

Halph-Price

Member
You don't have to make a new door object for each entrance. You can reuse the same door object throughout the game.If you want a different looking door, just make a copy of the door object and assign a new sprite.

You can change variables in the the room editor. Just place the door where I want it to be and specify the co-ordinates for where the player will appear in the next room.

So if the door in room 1 leads to room 2, just figure out where the player should appear in the next room and punch in the x,y coordinates. Also specify that its room 2.

This way you can add doors to all your rooms so your player can enter and exit the room as and when he likes. But just make sure that the x,y coordinates where player appears is not directly on another door object, or it will cause an error.

BTW I'm not really a programmer. I'm just using code that someone here gave me a long time ago. Its simple but it works fine for me.
OH, I get you now, by double clicking on the object to get that. Ya, there wasn't any real way I would have discovered that object on my own. Thank you so much friendo. So the creation code runs after the normal create event, and that makes life so much easier. Thank you so much, I knew I was missing something important. Wonderful.
 
Top