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

GM:S 1.4 Creating a seamless open world.

Discussion in 'Programming' started by nicktheslayer95, Jul 6, 2016.

  1. nicktheslayer95

    nicktheslayer95 Member

    Joined:
    Jul 3, 2016
    Posts:
    79
    I've been toying around with an open world engine for a little while now, and it's mostly consisted of a lot of rooms connected by doors and warp points. I'm becoming a bit more interested in allowing the game to give the illusion of the entire world being one room, rather than using a fade transition between areas.

    Are there any good sources that show how I can create an entire overworld in a single room efficiently, or give a convincing illusion? It has to be pretty dynamic, so the world being within a single room would be ideal. I've googled this, but I can't seem to find any sorts of tutorials or examples that suit my needs.
     
    Bentley, MechaZoid and Cpaz like this.
  2. Cpaz

    Cpaz Member

    Joined:
    Jun 20, 2016
    Posts:
    310
    The only thing I can imagine (and it would be difficult) is have sort of "transition points" basically have the transition point (say for example a bridge) look exactly the same in both chunks (rooms) of the world, and somewhere along the bridge, it loads up the next chunk at the same transition point and hopefully the same point on the trigger of the transition (to give the effect of it being a single consistent world.
    This is purely theory, I don't know if it's possible, or effective. But it's an idea.

    EDIT:
    To elaborate the idea better, use this diagram:
    [​IMG]

    A is one chunk (room) B is another. A union B is the transition point (bridge).
     
    ParodyKnaveBob likes this.
  3. nicktheslayer95

    nicktheslayer95 Member

    Joined:
    Jul 3, 2016
    Posts:
    79
    I feel like if I were to do that, the game would twitch in between rooms, when the character jumped to their new coordinates for each room. Unless I can break one giant room into chunks and load them individually, but I have no idea how to do that.
     
  4. Cpaz

    Cpaz Member

    Joined:
    Jun 20, 2016
    Posts:
    310
    Maybe with buffers? I feel that that would do this, granted I've not even touched buffers so I can't say. But I would mess around with a variety of ideas and see what would work best. The last thing I would go with though, is one large room, with a constant use of instance_deactivate functions, that would probably result in undesirable effects.
     
  5. Zodaris

    Zodaris Member

    Joined:
    Jul 2, 2016
    Posts:
    103
    It may twitch it may not. Depends on how efficient you were with it. If most of your objects are persistent that may help I think (as in, lower the amount that needs to be loaded all at once). I feel like that method is what games like Pokemon use (granted the newest I've played is Emerald so I have no idea how they do it now).

    One possibility that could work, is if you use the feature that makes rooms loop vertically and horizontally. Use a script or object to keep track of what needs to be made where and destroy the rest. The player could walk on forever technically. If you did it right, it would only have to load a little at a time with no big jumps. But the room size would have to be a decent size so the player will never see through the illusion and so things off screen can still do their job, at least before the player goes too far away from them. You could use a ds_map, array, or something to keep track of the positions of characters and such so you can destroy them then create them at will.

    But I'm not sure. Never tried it before. Would be mighty difficult and take a lot of code though. I think. It may not even work I dunno.
     
    Cpaz likes this.
  6. Cpaz

    Cpaz Member

    Joined:
    Jun 20, 2016
    Posts:
    310
    Pokemon was actually what came to mind when I though that method. But yes efficiency is definitely going to be a factor. Primarily keeping track of the camera/character positions during the transitions.
     
  7. Ctl-F

    Ctl-F Guest

    Just going to throw this out there, you could set up a system similar to minecraft chunks, where as the player moves, new chunks are loaded and old chunks are dropped as needed. It would require more work on your part, but it would give you actual seamless open world.
     
  8. nicktheslayer95

    nicktheslayer95 Member

    Joined:
    Jul 3, 2016
    Posts:
    79
    I cant find any tutorials for chunking rooms, does anyone have a source of info or a tutorial they know of?
     
  9. kburkhart84

    kburkhart84 Firehammer Games

    Joined:
    Jun 26, 2016
    Posts:
    467
    I don't have a tutorial, but I will give you something to think of that might get you on the right track.

    You can't keep everything loaded at once. Break it down...you need several things. You need a way to manage what is and isn't loaded. You need a place to store the world in, which in general will be a bunch of stuff that isn't loaded. And you need something to create these chunks in.

    1. About what is and isn't loaded...you need an object of course. It would know where in the world you actually are. It would also make adjustments to all the objects, for example to keep you from straying too far from the actual world center despite being in any location in the world. This object also relates to the other stuff I'm talking about. As you get to edges of chunks, this object would load the next chunk into memory, creating the objects that are stored. It would also, as you get farther away from the previous chunk, it would unload it.

    2. Place to store the world in....I recommend you read up on files, specifically binary files, and I'd learn about data structures too. The data structures and arrays that GMStudio provides are good ways to keep the world stored. You could keep a tiled world, and in an array or grid store "chunks." The array itself would probably just be numbers indicating what object/tile to put at that location. Though it could also be a sort of structure where you can just have objects with positions, etc... In either case, you would be able to create the objects either from an array, or from the other fashion of data.

    3. Method of creating the chunks...this is up to you. You could create an actual separate program. You could plan methods, etc... to just create the structures directly in code...there are options for this. The best method depends on what you can do, as well as how much world it is that you need to create.
     
  10. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,596
    To actually pull this off, I can at least give you the theory. The coding though... hmm... so here's how I would do it:

    You game is one room, huge enough. In that room, you have a "world manager" object. Your game would basically be a grid in which you would load and unload cells. For this to work you would need your world manager to spawn your tiles and objects.
    The scrolling would also be done by that manager, your character staying in the middle of the room. (you move the world that you spawn in chunks, basically). I wouldn't bet that its easy but definetely doable and maybe worth it if you REALLY want to put the time and thought. But if its just to save us from some transitions, I am not sure. You could go the "A Link To The Past" style and transition from room to room with a "slideshow" style transition instead of fading in/out.
     
    Zerb Games and Cpaz like this.
  11. Xer0botXer0

    Xer0botXer0 Member

    Joined:
    Jun 29, 2016
    Posts:
    670
    Interesting concept.

    This method is based on the multiple rooms idea.

    Here's what I'd do (with instances)

    Every room has a hollow rectangle, where the outline is of specified width/height(thickness), this outline
    will be used in coordination the x/y position of an instance, every instance has two sets of coordinates.

    When an instance is within the outline a boolean is enabled and they're given a second set of x/y coordinates followed by disabling the boolean.

    The second set will depend on one of the four directions of a room, that set is also then given the room id of the room in that direction, you'll know how to add it because you'll have the room id somewhere in your current transition code.

    then the instance will have a step event that will check to see if the instance moves out of that outline, if it does remove either the first or second set of x/ycoordinates and clear the room id. You can as probably already have check to see if an instance should exist in a room based on a variable that holds the room id that it's in, in this case you'll have two.

    So that's how I'd approach it you'll pieces of every room surround the current room in that room. (instances that is).


    When it comes to backgrounds it all depends.
     
  12. JML

    JML Wabbajackalope

    Joined:
    Jun 22, 2016
    Posts:
    350
    just to throw out an idea.

    why not actually have the character passing in front of and behind objects in similar theme to the overlapping of rooms if you put some object, any object, in front of the player at the transition point so you cant see its body then that will make the transition much easier because you dont have to focus on the precise orientation or position of the player, just duck behind a tree, your behind a tree for a second invisible, move to new room jump out again.

    the only real problem i could see with this though is if you have npcs jumping between rooms both because you would have to despawn them and the rooms when they are too far away and if not synced correctly ducking behind a tree could cause an enemy to vanish.

    also big problem exists with the range of mobility the player has on the screen if you always have the camera fixed in the middle then the transition will be much easier but if thats the case you will have allot of extra graphics along the edges because walking into a wall will turn half the screen into rocks.

    the only real question is if you want to do what was meantioned before with slideing transitions like link to the past or one seamless grid.

    the main problem is i dont know how to make two rooms appear at once although with that said if you could establish an "overlap grid" with a central object your doing measurments from, im sure their would be a way to establish that position x and y in room 3 is equal to position x and y in room four, swap the rooms move to the correct location but this would not address maintaining the soomth walking animation of the player as it jumps from one to the other.

    or here is another crazy idea, what if you only created one room and had ALL the objects in the room move while the player doesnt??? maybe it would be a bit intensive on the machine but yyc can handle 2000 zombies at 60fps, but under this line of thought you would have the background shift as you walk and the entire room would move around the player instead of the player moving through through the room, that would provide seamless transition and from the players perspective they would not be able to tell the difference.

    anyhow dont mind me just pondering the room trying to play the player and the player being the only stationary thing in the room even if the walking animation doesnt make you think that.

    good luck! :)
     
  13. Snail Man

    Snail Man Member

    Joined:
    Jun 20, 2016
    Posts:
    282
    You could have a system where you store screenshots of the empty rooms at the beginning of the game, then draw them in the appropriate places during the game to give the illusion of the open world. Assuming one room = one view size, you'd only need to draw 3 screenshots at the most, and you could have the rest taken out of memory when unneeded to reduce the load. Just a thought. As long as there was nothing moving in the rooms, you could also make the room screenshot update as you leave it, to keep the world consistent
     
  14. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    If the rooms are made up of tiles, just dump all the tile data to a file. When you need a room's tile data, load the corresponding file into a buffer and retrieve the tile data from the buffer. Add the tiles that need to be visible to the room and delete the tiles that don't. You'd only need 4 files open at any one time (typically the room you're in, then if you're on the right half of the room you'd need the room to the right, if you're on the left half you'd need the room to the left, if you're on the upper half you'd need the room above, if you're on the bottom half you'd need the room below, if you're in the corners you'd need the room diagonally across - so at any one time you'd need the room you're in, the room vertically in view, the room horizontally in view, and the room diagonally in view.
     
    Luke Pierson likes this.
  15. Hey there - I've been playing around with a "seamless world" myself. Its far more complex that I ever realized it would be.
    As many of the people above have mentioned, you really have to break the world down into smaller pieces first - all of the objects in the entire world (depending on the size of your game) would likely be far too much for both GM and the average computer to handle. So, creating a system to dynamically save/load your content would be the way to go.

    Here is the approach I am attempting to program currently -
    Note - I'm in the very early stages of development on this, so it may not work... But it looks good on paper to me ..

    Lets say your "overworld" is one large map that could be equally divided into 16 smaller pieces.
    These smaller pieces are individual rooms in GM.
    Something roughly like this =

    [01] [02] [03] [04]
    [05] [06] [07] [08]
    [09] [10] [11] [12]
    [13] [14] [15] [16]

    Lets say the player is in room 11.
    You'd want to have rooms 10, 7, 12, and 15 loaded as well.
    That way the player can move in any direction from his current position, and the content would already be ready to go.
    So, lets say the player moves to the room to the left of room 11...
    Room 10 is already loaded in memory, allowing you to move to that location.
    From there, you would drop room 12, and have rooms 9, 6, 11, and 14 loaded.

    So basically, you are always dynamically keeping all of the rooms surrounding the room you are in loaded and ready to go.

    I believe this is a really rough overview to how AAA titles get away with these massive open world games that are so popular these days.
    They are only loading content that is within x radius of the player - no sense in wasting resources on items that are on the opposite side of the world from the player.
    Just store that information, and load it when you need it.

    And keep in mind, that even though GM isn't the most limitless game engine - it can do quite a lot.
    The rooms in the prototype I am currently working on are all 10,000 x 10,000 px in size - which is quite large..
    Now if you take that room and add it to 63 other rooms of the exact same size - you've end up with one massive map at 80,000 x 80,000 px. That should be a good starting point for your RPG world..

    Good luck!
     
  16. Eisot

    Eisot Member

    Joined:
    Jun 21, 2016
    Posts:
    22
    Jihl likes this.
  17. ConsolCWBY

    ConsolCWBY Guest

    I would honestly try to track this guy down and ask HIM a few questions.
    His idea is fascinating...
     
  18. piksil_demon

    piksil_demon Member

    Joined:
    Aug 16, 2016
    Posts:
    235
    make the room textures go past the warp point, and to the edge of the players max field of view (+ 1 for good measure), making it llok exactly like the corresponding point of the next room
     
  19. AnimusRex

    AnimusRex Guest



    There's a series of tutorials Arend Peter does to make seamless randomly generated worlds based on a heightmap, check the series out to better your understanding. There's I think 4 in total.
     
  20. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,840
    Some ideas...
    • You probably would want to use different rooms for the insides of houses so they can be bigger on the inside, so if you could cheat a bit and have 'indoors' areas (everything from houses to forest clearings to cave antechambers) as area transitions nobody would notice. Even a few of these would be able to reduce the game world room size with an order of magnitude.
    • If you go with the "rooms have identical loading zones" approach, you would have an easier time making them if they are easier to replicate. If it would be possible to keep them straight lines, such as bridges and stairs, try going for that.
    • It could also be worth a shot to always warp the player to the edge of the screen, let the view go outside the bounds just for that transition, and copy all the tiles/decorative objects along the appropriate edge and carry them over to the next room (using e.g. a global data structure). More work, but it would save you the work of having to manually copypaste the transition zones between maps.
    • For chunk loading, you can spread out the actual loading if you can do stuff in the step event instead of with a loop that does everything at once - that approach might create noticeable lag spikes breaking the illusion. I'm not quite sure, but I believe creating instances in particular is the slowest part of this step, while reading file data is slow but faster. (Probably depends a lot on how the data is stored as well, reading from a binary file should be faster than reading from a text file, and it also depends on the number of instances already existing in the room and your disk read speed, etc... though if the file gets cached after you read from it the first time, it should be a lot faster than if you're reading directly from the drive, and stuff like that). Probably wouldn't hurt to spread out file loading either, I guess.
     
  21. Salvakiya

    Salvakiya Member

    Joined:
    Jul 17, 2016
    Posts:
    84
    TADAA!

    I followed this tutorial then modified it to not be constrained to a size.... my world is as large as your computer specs allow! ;)
     
  22. spe

    spe Member

    Joined:
    Aug 25, 2016
    Posts:
    102
    If I'm correct, this is what some top RPG games like Destiny do, except in 3D. It shouldn't be much different for a 2d world, in fact it should be easier. I think it's pretty simple in theory, although it may be a bit more difficult to implement. Just as long as there are only certain paths that can be taken to get from one area to another, you can have the rooms look exactly the same in those areas, represented by the 'AnB' section of the Venn diagram in the quote, and jump from one to the other. I don't think it would be 'jumpy' just so long as you're not trying to load in too much stuff in the next room. I imagine the transition would be seamless as long as the two rooms look identical at the meeting points, at a big enough area to completely fill the view when you reach the transition point. If you've played Destiny, you'll notice that the paths, roads, hallways, or anything else connecting one area to another are usually fairly long and narrow, and they usually have some twists and turns so you can't see the next area before it's been loaded. I think they even start loading the next area before you reach the transition point, since it's a big 3D room with lots of content to load. Such a thing probably won't be necessary in a 2D game. The result is a (mostly) seamless open world game. (I say mostly because you get a noticeable 'seam' when you try to enter a new area with another player; the result is the player disappearing and reappearing a few feet away in the new room. Also, on the old gen consoles, you may get stuck at the transition point with a 'loading' message on the screen as the old hardware struggles to keep up. Still, I think it provides a good example of the kind of seamless transitions you're looking for, you just have a be a bit crafty with your room layout to give the open world illusion).
     
    Cpaz likes this.
  23. Bruno A.

    Bruno A. Guest

    I'm currently implementing a true open world into my project. I created a controller object to draw 9 portions of the game world that are adjacent to the player's position at the time. All world portions are stored in an array at the beginning of the game then as the player moves around, I use a loop to update the adjacent portions to draw. I'm using a pretty big world and 1 room only(90000x90000) with each portion being 900px, so far I didn't notice any performance drop. The background is working, now another controller for the objects must also be created.
     
    Last edited by a moderator: Aug 13, 2017
    SirPandaMaster likes this.
  24. Bruno A.

    Bruno A. Guest

  25. Have the area connecting the two rooms be identical, like in games like Half-Life and Portal.
     

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