Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My game consists largely of "sea" tiles with sections of tiles that form "islands". The sea tiles are all exactly the time.

The map itself is pretty large and only going to get larger. I'm trying to think up ways of reducing the map size due to the majority of it being the same.

My initial thought: to somehow make it so just the islands are stored and their location within the map. So the map would consist of map size and islands only.

Any other suggestions or perhaps how I could implement the above whilst still being able to use a* pathfinding?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Can you have a separate tile map for each island and just store where that tile map should be located?

Then you could render the ocean by finding the top left most visible tile by doing math.floor(visibleArea.left / tilewidth) and math.floor(visibleArea.top/ tilewidth) and drawing the water texture for every tile for as many tiles as fit vertically + 1 and horizontally + 1, as long as the Y value was under the water level.

Then you just need to render any visible islands.

So you memory foot print should be your textures and as many tile maps as you have islands. Which should be a lot smaller then one huge tile map of the whole world.

Edit: Wow totally missed the "Any other suggestions or perhaps how I could implement the above whilst still being able to use a* pathfinding?" sorry for the useless answer hopefully the below should help.

There are two ways to represent graphs. Adjacency graphs and edge vertex graphs. I prefer adjacency graphs for tile maps because you don't actually need to maintain an adjacency list just grab any of the the 9 surrounding tiles straight out of an array or generate them.

Point being for A* on a tile map you don't actually need a data structure containing the adjacent vertices since you can easily calculate it (assuming the graph would have a vertex for every passable grid tile would be adjacent to all possible vertices that are touching it).

You simply have to generate the adjacency list for every vert you pull a off the open list excluding any nodes on the black list or that are impassible. You can assume that all nodes are passable unless the vert is within an area that contains an island, in which case you will use the data from the tilemap to exclude any impassable tiles/verts.

Only real downside of this is that the graph is very dense. However, I doubt this would be an issue because from how I understand you game to be very little wasted effort on branches being explored that will dead end.

More simply you can just make a bee line for any targeted tile when in the water and then use A* to navigate any islands you come across. There's only two cases I can see here

Case 1: You want to get to a tile on current island

Use A* to get from the first tile in the tile map you hit to the target tile.

Case 2: You want to get to a different island

Use A* to get from the current tile to the tile on the tile map that is closest in real space to the tile you want to get to.

share|improve this answer
    
you can load/unload additional locations on fly, depending on where currently you are, in loaded part of the map. E.g if you are 75% of loaded location width more, then load additional location. Of course if it's veeeeeeery big, and you cannot load it at once. –  bobenko Dec 23 '11 at 14:05
    
Sorry I didn't fully read the question so I just realized I didn't help answer anything. Hopefully my edit helps. –  ClassicThunder Dec 23 '11 at 23:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.