HELP: how to do doors and room transitions in GM

Help I am not very expereanced with GML and I am making my own metroid engine. I don’t know C++ at all.
I use the actions mostly. I use code too, but only when i need to.

I need help on how to make a transition from room to room, and keep variables like what weapons you have. also, how do upgrrades work? I get confused most of the time i try to figure it out myself.

also when I go from one room to another and go back into that room, then samus goes back to the start of the room. also, do I have to put a samus in every room?

and when I make the room persistant, when I go to a door, and reenter that door, the screen flickers, going back and forth from room to room.

and do i have to have diffrent door objects for each room?

and how do i get elevators to work?

Uhh. AND how do saves work?

clicky the ‘persistant’ box on samus.
Done, you now keep all your upgrades.
clicky the new object button, and put in the collisoin with samus something like
samus.x=xx
samus.y=yy
room=roomyPlace said object in a room (It needs a sprite as a collision mask, but make it invisible) and right click it. or is it crtl+rc? W/E whichever brings up a menu, then go to the bottom, and go into the ‘creation code’, and put
xx=(w/e x you need samus to be in the next room)
yy=(similar)
roomy=the room_index of whatever place you want to warp to.

If you don’t get it, just say so.

A safer method than making Samus persistent would be to make all of her variables global and initialize them at the start of the game. So, for example, instead of like “Samus.weapon” (or just “weapon” if you’re using it inside Samus), it will be “global.weapon”. That way it will carry over to other rooms.

When the game starts just set them all to default (like “global.weapon = 0;”) in some initializing object on your title screen or whatever, so Samus doesn’t have to mess with them in her create event. So she won’t reset them every time you enter a room.

To have her start the next room at a certain spot (ie. in front of the door of the room you came from) you could also use global vars (something like “global.startx” and “global.starty”). The door object should set those variables to correct place before going to the new room, and Samus should teleport to that position in the create event.

PY explained how to get each door to have different destination rooms and coords. Right-click + ctrl on each door instance to get the creation code box, in which you can set the vars for it to use later.

i don’t get it.

Well, when you rightclick+crtl, the creation code is akin to putting things in the ‘create’ event, except they can be different for each instance, so no more ‘warp-toroom1’, ‘warp_toroom2’, etc!
Is there anything else you don’t get
@t92, very true, I have all of my pickup variables global-led and inside my HUD object, so I can be quite flexible with Samus.

i mean, how do you get the door to teleport her to the right place before you’re even in that room?

Unless she’s set to persistent, you can’t. What you do is set the coordinates in global variables, which get carried over to the next room, and then have Samus teleport to those coordinates at the very start of the room (in her create event). So like this:

Upon starting a new game, just before going to the first room of controlling Samus:
global.startx = … ;
global.starty = … ;
// Where she starts in the first room of the game

Door instance creation code:
gotox = … ;
gotoy = … ;
gotoroom = … ;
// Destination room and coordinates for this specific door

Door object collision with Samus:
// Optional room transition code would wrap around this
// But that’s another story
global.startx = gotox;
global.starty = gotoy;
room_goto(gotoroom);
// Tell Samus to go to the coordinates this door leads to
// And then go to that room

Samus create event:
x = global.startx;
y = global.starty;
// This is when Samus actually goes to that point

Hard to explain without just writing the code. Get it, though? Global vars stick around from room to room, so you can place coordinates in them for Samus to teleport to at the start of the new room. Just don’t forget to set them correctly each time you go to a new room, or she’ll end up going to the last room’s coordinates in the new room–probably not good.

Also, I just happened to notice that this topic is… in the wrong board, and shouldn’t be its own topic.

In the future, fangame questions should go here:
http://z3.invisionfree.com/MP2D/index.php?showtopic=407

Somehow I didn’t notice that earlier. I won’t close it right now since we’re already into a discussion, and I don’t think moving the posts into it would leave any sort of notice here as to where the topic suddenly went.

what do you mean by “samus create event” ? I thought that samus already did that.
and how does the “gotoroom” variable transfer over to samus?

and do i put the collision event inside the door object?

and when i do it, when i arrive in the next room, i don’t get poofed to the coords, eventhough the code is in samus’s create event.

This is by far the funniest post.

Double post followed by spam…

@bl, this isn’t MSN, you can sometimes not get answers for days.

there’s the problem.
you might want to make something simple before a metroid engine.

?
When did he say anything of the sorts <_<

You have to know how to bloody program!
M’troid is a complex beast, start with something simple, like Super Mario Remake #xxx

I have some ideas for metroid levels, and i need an engine to make it happen. i dought thatr you guys are gunna give away the source for the old engine (the one used in demos before 3.0), and you guys say that i can’t make one myself, and I am DEFINITLY NOT gunna just say fuckit and abandon these levels, sence i have been making these levels in my mind since i first played super metroid.

HEY :imp: :imp: :imp: . I’m just not as clever :imp:

  1. The create event is where you can make extra stuff happen when Samus is created. That’s where you place that bit of code, but I don’t think it’ll work if Samus is persistent.

  2. “gotoroom” is a local variable to the door instances only, so it doesn’t get passed over to Samus. Samus doesn’t need it though–the doors call “room_goto(gotoroom);” to send her to the next room and then the info isn’t needed again. Samus only needs what position to teleport to once that new room loads.

  3. Yeah, sorry, that was unclear. That code was written for inside the door object, its collision with Samus.

  4. Try having Samus not be persistent–I don’t think the create event gets called when she is, since she doesn’t get created again when a new room loads.

Hopefully you can get it to work now. If not, I might find the time to make a sample program for you to look at, but it might be a while as I’m pretty busy lately.

Heres an old build of my engine, it’s GM7 registered, but you might be able to learn something from it.
http://metroidr.brpxqzme.net/index.php?act…m=02&c=4&id=195

i got it working! :smiley: what you do is put the goto code in the rooom create window. if you do this, you can have samus persistant. i have all my vars inside my hud object now too :smiley:

only prob, is i don’t know if it works gompleatly yet. i did think about it for a week though. :smiley:

oh and the file is a GM6 file. but that’s ok tho, because GM6 pro is what i’v got :smiley:

Clever–and glad to hear.

And, that ends this topic. Remember, future fangame questions go here:
http://z3.invisionfree.com/MP2D/index.php?showtopic=407

You won’t always get off so easy. :>_>: