Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seamless scrolling tilemaps

Tags:

c++

c

dictionary

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.

like image 860
rcapote Avatar asked Feb 11 '26 19:02

rcapote


1 Answers

This is exactly like what I'm trying to do with a game I'm writing in FreeBASIC. What I'm doing is slightly different, but maybe it can be of some help.

I have a 1024^2 world map (so I can generate it fractally). Each land square on the world map is a REGION map (a miniature kingdom with a procedural history), but I made region maps very easy to generate. The region maps are 128^2 and I have four of them in a 256^2 array. When you get near the edge it moves the maps and creates 2-3 new regions (though it only makes ONE history-- the region the player is in).

Inside of these are 256^2 ZONE maps, which also tile 2x2 in a 512^2 array. Again, when approaching the edge it moves and generates new ones.

I tried a 3x3 grid some time ago, but had to reject it as inefficient.

like image 154
Baccar Wozat Avatar answered Feb 13 '26 09:02

Baccar Wozat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!