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

GMS 2 Saving Rooms and Instances

Discussion in 'Programming' started by Will Roberts, Feb 14, 2020 at 2:39 PM.

  1. Will Roberts

    Will Roberts Member

    Joined:
    Friday
    Posts:
    10
    Developers,

    I am trying to wrap my head around a concept that I am not getting. I am trying to create randomly generated rooms that will remain after the character transitions to a new room. I'd like all of the objects to remain too.

    I have:
    room_start (where the o_player starts and is persistant)
    room_dungeon (this room has two objects, the o_camera and the o_level_generator)

    When I descend, a new room is created by using

    global.new_room = room_duplicate(room_dungeon);

    and then

    room_goto(global.new_room);

    What I am trying to do is; have a static room at the top. Descend an untold amount of times and be able to ascend back up through the rooms that have been previously created.

    Right now, I can descend 10 times but when I use the ascend, it takes me back to room_start. I am about to create a variable that is a counter for room_level and concatenate that to the global.new_room variable so that I can store multiple rooms and then I will just use that variable on the room_goto based on the current level.

    Any concepts on this topic to help me understand would be greatly appreciated.

    Will
     
  2. Jordan Robinson

    Jordan Robinson Member

    Joined:
    Jun 22, 2016
    Posts:
    94
    Could you use a ds_stack to store the ID of each room you create? Then as you move back up through the rooms you would pop each one from the stack so if you moved back down you would get a new random room. Or if you used a ds_list or something then you could keep each randomly generated room so the player could move between those and then only generate a new random room when entering a previously unvisited level
     

Share This Page