Thursday, December 14, 2017

2d - How to handle a huge map?


Generically speaking, how would you handle a huge 2D Map of which only a part is displayed? Imagine the old top-down racing games like Micro Machines.


I would know how to do something with a tile-based map, but I want to create completely custom Maps.


Target Devices are iOS, Windows Phone 7, Android, Mac and PC.


Assume the Map is too big to fit to fit into a single Texture. Would I have multiple textures, 4096x4096 each and load them all into RAM? Seems wasteful, and if textures are uncompressed I might actually run out of graphics memory.


Would I only load the max. 4 Textures that I need at any given point (when I'm at the intersection)?


Or would I have one huge image file and load parts of it? In that case, are there any image formats that make it easy (O(1)) to find the file offset and length which I would have to load?


Or is there a completely different algorhithm? Are textures the wrong idea?


How would you implement a game like Micro Machines?




Answer



In a map that is built from tiles, I have given a fairly full explanation of the approach I've found to work best down on the low end devices:


How should I represent a tile in OpenGL-es


Memory is the memory used by the tiles (not how many times they are reused) and the relatively small amount of memory used to index where to place each tile.


Maps like Terraria are entirely possible!


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...