0
\$\begingroup\$

I am developing an RPG game where there is a main world map, locations such as towns or ruins on that map and buildings in those locations where players can interact to go into. For example, I have a map and my character goes to a local town where there is a inn that I can freely enter and interact in. Once I wish to leave the building, I leave and I'll be at the same position that I had once entered the building from, albeit facing the opposite direction. The one problem that I have with imagining a map system that could be complex like this are the coordinates. Is there a way of accomplishing this with the use of universal coordinates, such as only one x and y position throughout all 3 stages of this map system, or would I need to have 3 coordinates, a Map coordinate system for the world map, a Local coordinate system for the town or ruin and a Temporary coordinate system for when I am in a building? Also, is there something in libGDX that could help out with this?

\$\endgroup\$
1
\$\begingroup\$

Use user data in your tiled map. If you use tiled, you can create object layers and use the objects as spawn and teleport points. For instance, when you exit a cave, you have a spawn point object on your main map set as exit_cave, then set the player position to the exit_cave x and y.

If you're not using a tiled map, I suggest creating a map class and create a hashmap using a string and vector2 for each map you have loaded. That way when you exit a cave, you can easily get the position of the exit from your map to be loaded.

Example. At init: create instance of map class, Main map and Cave map. In your Main map hashmap, put two objects. <"Cave_enter", new vector2 (0,5)> and <"cave_exit", new vector2 (0,4)>. In your cave map hashmap, put two objects. Main_enter and main_exit. When you want to change from main to cave, load the cave map and set the player position to Main_enter. When you leave the cave, load the main map and set player position to cave_exit.

Sorry if this is confusing to you. English isn't my first language

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.