How do I save a room (to get back there)?

0 favourites
  • 5 posts
From the Asset Store
Helping streamers give their viewers more excitement.
  • Hi everyone,

    I am currently testing a level design where several rooms are generated randomly. Each time the player changes room, a new one is loaded and the player finds himself at the entry point of this one (a bit like Cult of the Lamb).

    For the part of loading the presets rooms I was inspired by dop2000's demo (congratulations to him, it's really well done, you can find some of his demos here).

    My player can therefore move from one room to another but however, I have not found a way to save the rooms he has already gone through.

    For example, if I want the player to go back, it will randomly load a new room and not the room he has already visited.

    I think there is surely something to do by saving the data in an array or a json file for example but I don't see how it could be done.

    Besides, it could also have a mini-map which is built simultaneously according to the progress of the player.

    If anyone here has a method or a solution, I'm all ears!

    You can already test my progress on this file, the purpose will be quite different but it is a basis for understanding how it works.

  • It may be better to ask someone more experienced than me, but your best bet is probably arrays. If you need to save a larger amount of arrays/levels, you could change each array to JSON format and save the JSON data in another array (So RoomsArray Slot 1 would be the data for Room1, etc)

    This may not be as reliable, but if you used the Advanced Random, since it will always generate the same random numbers, it would generate all the rooms the exact same way.

    Hope this helps, if not tell me or ask someone better (like dop2000)

  • Ok I think I get it (a bit). I thought I could save every new room created in a JSON without using arrays. In the end there will be a lot of informations and variable for each, it could not be the easiest way to manage it.

    I also started to make a mini map. The interesting thing is that I can also probably save variables on it like "how many entrance there are in a room", etc… So when the player come back in it, the mini map could maybe ask the JSON all the stocked variables to "rebuild" the room?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Honestly I'm a bit lost as well. I know how to store the rooms and stuff using arrays or JSON, but getting infinite storage is what the problem is. You could probably have an array of your JSON data, each storing one board, and then if it fills up you can expand the array for more slots.

    As for getting variables from JSON, you would probably have to load the data into an array and check a specific slot to find a number, however I have never done something like this so I'm a bit confused as well.

  • Same for me. I just started to understand how arrays are actually working and I really need to get the logic about it.

    But I did get an important information: all objects has a AsJson expression.

    That's mean that everything about a sprite (size, position, actual frame, etc…) can be saves and load quite easely. Even variable I guess.

    It you create an event to save everything in your array like:

    + System: For each Sprite -> Array: Insert Sprite.AsJSON at index 0 on X axis

    Then if you want to call it back:

    + Array: For each X element -> System: Create object Sprite on layer 0 at (0, 0), create hierarchy: False, template: "" -> Sprite: Set from JSON string Array.CurValue

    Seems it works pretty well but I encountered a major problem: This is not working with families. It can't recognize sprites with their name and it mix everything when you call it back.

    And that's a big problem because I don't want to put this for every single sprite in my game (yep, I'm lazy XD).

    For now I have no solution.

    But even if I need to figure it out, I need to assign a new variable for each room that every single sprite in it can refer to.

    And I may have the solution for this with the mini map I'have created here:

    https://www.dropbox.com/s/yemjzks3vwv11xf/LevelGeneratorTest.c3p?dl=0

    For now it's not that bad even if I didn't really figure how to detect the entrances of the rooms already created, but I'm going on.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)