How might one replicate the map looping used in rpgmaker games like yumi nikki, .flow, and yume 2kki?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LaulessFun

I’m wanting to make a game much like yume nikki, but as someone who’s still learning to use godot as I work, I’m still searching things up as I go. And I’ve run into a block, as I haven’t been able to find any documentation or tutorials on implementing the looping maps sometimes seen in rpg maker games.

And I’ve had little luck in searching “looping maps godot” or “world wrap godot.” Closest I’ve found is the procedural generation looping map and the screen wrap tutorial in the first two links.

https://www.nelsonfritsch.de/post/creating-an-endlessly-repeating-map-in-godot/ -
https://kidscancode.org/godot_recipes/2d/screen_wrap/ -

My problem with the first one is that it involves portions of code I don’t understand yet, so I’m unsure of how I might set it up with a tilemap instead of random generation, let alone if that’s even possible. And though the second one looks pretty close, I’m hoping to have the camera zoomed in on the player and following them so that the transition isn’t noticeable, which doesn’t really look possible without making duplicates of the map. (Which I honestly think is pretty inefficient.)

So long story short, anyone have any ideas on how to do this or where I would even start at an attempt? I’m willing to sludge through the learning curve this will obviously have.

EDIT: Ok, so to clarify, I know how to make the player character do a level wrap (warping from one side of the map to the other), it’s making the transition seamless that I’m finding little help for. I’m hoping to avoid the solution of duplicating the map itself at each edge, since I’d then be stuck with 4-8 copies of the map circling the map itself.

:bust_in_silhouette: Reply From: exuin

Not tested, but after movement, I think you should check the player’s position and if it matches the position of end of the screen, you should set the player’s position back to the beginning of the screen. I can elaborate more if you need more explanation.

Problem is, that’s something I know how to implement. It’s the transition itself that’s driving me up the wall, since I don’t want players capable of noticing the map edge, or when they’re teleported. Unless you had something more in mind?

In either case, thanks for the idea.

LaulessFun | 2020-09-29 03:36

You can extend the map past where the player is teleported back to the front, so the player won’t see it.

exuin | 2020-09-29 03:50

I’ll admit that is an option, and one I’ve even considered doing once I run out of time, but I’m hoping to maybe find something better then “add x extra space and/or duplicated sections” to the map.

LaulessFun | 2020-09-29 04:41

You would only have to add as many tiles as the camera can see from the edge. I think that’s a lot simpler than this tilemap looping solution.

exuin | 2020-09-29 07:03

Fair enough. Thanks for the help.

LaulessFun | 2020-09-30 04:55

:bust_in_silhouette: Reply From: jonbonazza

One way to solve this is to have two copies of the map that are created in a way that they visually tile horizontally. Always have two instances of the map in the scene next together at the same time. When the player enters the bounds of the “next” map, making it the “current” map, move the “previous” map to be positioned on the other side of the “current” map. Think of it like your two maps are “walking feet” You are placing “one foot over the other” as the player character moves from map to map.

EDIT:
If the player character needs to be able to go backwards as well, it gets a tad bit more complicated. First, you’ll need three instances of the map at the same time instead of just two. Second, whenever the player moves to the “next” map, instead of moving the “previous” map to the other side, you need to move the “first” map (farthest left?) to the other side. Lastly, you need to reverse this process for when the player goes backwards to the “previous” map. I would treat the 3 maps as a Deque data structure (double ended queue). pop the next map instance off the appropriate side depending on the direction the player is traveling, change its position and then put it back in the queue o the other side.

Given that I want this to happen at both the north/south and east/west edges, I’d likely end up needing both yet another map (or two) and a more complicated setup, the first of which I would like to avoid due to how inefficient it would be.
(I’d also like the keep the player from actually walking out to an absurd distance, like x = 90,000 or something, considering the scale I’m making it at.)

The idea itself has merit though, since at a certain scale (assuming camera scale doesn’t change with the map) one would be able to mark “zones” in the map, and load up the extra maps as necessary whenever it’s determined that the player is within the zone. I’ll definitely be keeping the idea as a fall back plan if a better solution doesn’t show up in time.

LaulessFun | 2020-09-29 03:48