1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Room Change ideas?

Discussion in 'Programming' started by Halph-Price, Nov 26, 2017.

  1. Halph-Price

    Halph-Price Member

    Joined:
    Mar 20, 2017
    Posts:
    42
    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....
     
  2. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,373
    well u dont understand all the basics. try variables
     
  3. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    668
    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.
     
  4. Halph-Price

    Halph-Price Member

    Joined:
    Mar 20, 2017
    Posts:
    42
    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.

    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.
     
  5. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    668
    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.
     
  6. Halph-Price

    Halph-Price Member

    Joined:
    Mar 20, 2017
    Posts:
    42
    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.
     
  7. pixeltroid

    pixeltroid Member

    Joined:
    Jul 23, 2016
    Posts:
    668
    nvm
     
    Last edited: Nov 26, 2017

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice