A discussion came up recently about how to create a 2D side-scrolling multiplayer game that can have an looping level design (Think of Starbound and how their worlds are looping).
I thought the simplest way would be to have a rectangular map with trigger zones which could teleport players from one side to another. However the obvious issue with this approach is the case of having multiple players at edge of the map at once. You don't want to just teleport players in front of each other and you would need a way to transport players without having other players disappear.
To append this idea and fix the issue I came up with the following: have a trigger zone (red square in image) where players will be able to see a "clone zone" (green square). In this green square, objects from the opposite side of the trigger zone would be copied into its corresponding clone zone (can be seen with A & B shapes). When a player gets to the starting edge of the "clone zone" they are teleported to the other side of the map.
In this example Player 2 would think they are seeing Player 1, however they would actually be seeing his clone and vice versa.
This seemed a bit extreme and complex for the problem at hand. My question now is to know if this solution is a good approach to tackling the issue, or is there a simpler way to solve this problem?
Answer
This system with all these triggers sounds a bit too complicated and error prone.
You could wrap the position of the player using modulo with something like playerPositionX = playerPositionX % mapWidth
This way when your player reaches playerPosition == mapWidth
the playerPosition
will reset back to 0.
This solution could be extended with the whole rendering system.
No comments:
Post a Comment