• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML back and forth room

S

Swegm

Guest
Hi guys !

working on a Zelda kind of game, i need help how to use room transitions so if i enter and exit a door i would be in relative position to the door, yea I think you know what i mean :)

cheers ! have a nice weekend, (whats left of it)
 

OnLashoc

Member
If I remember correctly, on your hero object in the Collision event with the "Door" object put:

if room=*whatevertheroomsnameyourgoingto*
{
room_goto(*whatevertheroomsnameyourgoingto*);
x=*Horizontal value of where you want your hero to be when entering room*
y=*Vertical value of where you want your hero to be when entering room*
}

Obviously remove the * and change the name of the respective values.
 
S

Swegm

Guest
If I remember correctly, on your hero object in the Collision event with the "Door" object put:

if room=*whatevertheroomsnameyourgoingto*
{
room_goto(*whatevertheroomsnameyourgoingto*);
x=*Horizontal value of where you want your hero to be when entering room*
y=*Vertical value of where you want your hero to be when entering room*
}

Obviously remove the * and change the name of the respective values.

will try this right now, brb with info :D thanks !
 
S

Swegm

Guest
If I remember correctly, on your hero object in the Collision event with the "Door" object put:

if room=*whatevertheroomsnameyourgoingto*
{
room_goto(*whatevertheroomsnameyourgoingto*);
x=*Horizontal value of where you want your hero to be when entering room*
y=*Vertical value of where you want your hero to be when entering room*
}

Obviously remove the * and change the name of the respective values.
It worked ! BUT .... i hate BUT... anyway .. the door from the first room disappears when going from room_1 to room_2 and back to room_1
so the door seems to be limited to one time use :) did try something like

if !instance_exists(obj_door)
instance_create(door at bla bla bla position)

but it wont :/
 

OnLashoc

Member
Hmm do you have an instance_Destroy(); set somewhere for the first door you entered?

You can treat it a couple ways, the long pain staking search for what is destroying the door upon moving to another room and coming back, or you can add a room start event with something like

if room= whatever your room is called
{
instance_create(name of the door thats being destroyed)
x= where the door's supposed to be
y= where the door's supposed to be
}

Or you can make that first door persistent and use it over and over in ever room and set a bunch of "If room = then do this" in the Door Step event but it may not be the most optimized route..

I'm still a learner myself after about 1 year of GMS 2 off and on, but Im figuring it out :)

And my code may not be perfect, but I'm trying to point you in the right direction.
 
S

Swegm

Guest
Hmm do you have an instance_Destroy(); set somewhere for the first door you entered?

You can treat it a couple ways, the long pain staking search for what is destroying the door upon moving to another room and coming back, or you can add a room start event with something like

if room= whatever your room is called
{
instance_create(name of the door thats being destroyed)
x= where the door's supposed to be
y= where the door's supposed to be
}

Or you can make that first door persistent and use it over and over in ever room and set a bunch of "If room = then do this" in the Door Step event but it may not be the most optimized route..

I'm still a learner myself after about 1 year of GMS 2 off and on, but Im figuring it out :)

And my code may not be perfect, but I'm trying to point you in the right direction.

Im happy for your help, ive been using GM for almost the same time, i dont count the time when i was younger and just did drag and drop and thought i could make World of warcraft or something haha :D .. i will try your suggestions ))
 
S

Swegm

Guest
hmmmm can't get it to work right, this is my biggest problem so far in this game creation
 

OnLashoc

Member
I have to leave to take wife and daughter shopping, but ill be back in a few hours if nobody has helped further I'll see what I can come up with :)
 
S

Swegm

Guest
I have to leave to take wife and daughter shopping, but ill be back in a few hours if nobody has helped further I'll see what I can come up with :)
Sounds great :D I came up with a solution, my player doest want to spawn at right position now ... I will sleep now, so you'll have time shopping my friend haha, im in Sweden and its 22:40 here. my three year old son will wake up at 6:00 as usual ! haha


edit:

if collision_circle(x,y,8,obj_door,true,true) && room==rm_greenworld
{
room_goto(rm_underground_1);
if room==rm_underground_1
obj_player.x = obj_door.x
obj_player.y = obj_door.y +64
}
if collision_circle(x,y,8,obj_door,true,true) && room==rm_underground_1
{
room_goto(rm_greenworld);
if room==rm_greenworld
obj_player.x = obj_door.x -128
obj_player.y = obj_door.y +64
}

This is my solution i worked it out from your code, but coordinates are fu**** up :D
 
Top