tags:

views:

52

answers:

1

I'm working on a top-down rpg, and want to implement seamless scrolling maps. That is, as the player explores the world, there is no loading screen between maps and no "doors" to the next area.

I have two ways to break down the world. At the top level, I have "zones" which is simply a collection of 9 "maps"(These zones are only represented by directories). Within the zone, the 9 maps are organized into a 3x3 grid. I haven't figured out the best way to represent these maps yet, whether it's by index or by relative coordinate to it's parent zone. These maps are what actually get rendered to the user's screen. Given the size of each map, and the size of the viewport, I know that the user will only be able to see a max of four maps when they are on the corner of a map.

My problem is, how do I keep track of the maps and their respective offsets in code as the player explores the world? I was thinking about having a map<Point, Map*> with 0,0 being the map the player is current located in. If the player was on the bottom left corner of the map, then the map to the east would be stored in as 1,0, the map to the south would be 0,1 and the map southeast would be 1,1. The problem I foresee with this is, I'm not sure of the points are mutable, and if rebuilding the list every time the player moves into another map or a different section of the map would cause a problem.

A: 

Consider a deque of deques. That way insertions and deletions on all 4 sides are easy.

PigBen