Python Forum
Infinitely repeating 2D map
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Infinitely repeating 2D map
#1
I'm creating a 2D game with a top-down camera.  I think something that would make the game a lot better is if I could have the map infinitely repeat itself (there isn't any particular reason for there to be edges to the map).  In other words, I would like it so if you were to just keep walking in a straight line and saw 3 trees, you'll eventually see those same 3 trees again.

Normally, the concept of this isn't that difficult, where it could be something as simple as "if self.x>world.x: self.x=0" but there are a couple caveats:
1. The camera is constantly centered to the player, so as soon as you're wrapped to the beginning of the map, you'd notice the scene change.  You'd also still see the edge of the map.
2. There are computer players, where the AI is programmed to follow or evade other players based on their direction and relative position.  When a player gets wrapped to the other side, the coordinates of either the AI or the targeted player are completely different.


I don't really know of an effective way to handle wrapping.
For problem #1, I could just have it so objects are drawn twice that are a "world's width/height" apart from each other, but I wonder if there's a more efficient way of doing it, or, if whatever the solution to #2 may be could conflict with this idea.
For problem #2, I can't think of anything that wouldn't involve me having to re-write the AI's decision making, which is already a bit complex as-is.
Reply


Messages In This Thread
Infinitely repeating 2D map - by schmidtbag - Jan-18-2017, 08:36 PM
RE: Infinitely repeating 2D map - by ichabod801 - Jan-18-2017, 10:34 PM
RE: Infinitely repeating 2D map - by Mekire - Jan-18-2017, 10:39 PM
RE: Infinitely repeating 2D map - by schmidtbag - Jan-19-2017, 03:14 PM
RE: Infinitely repeating 2D map - by Windspar - Jan-19-2017, 04:52 PM
RE: Infinitely repeating 2D map - by schmidtbag - Jan-19-2017, 05:41 PM
RE: Infinitely repeating 2D map - by Windspar - Jan-19-2017, 06:45 PM
RE: Infinitely repeating 2D map - by schmidtbag - Jan-19-2017, 07:02 PM
RE: Infinitely repeating 2D map - by Windspar - Jan-19-2017, 07:15 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020