I’m working on roguelike, and we’re hopefully about 3 weeks from releasing it. The programmer I took over for wrote a minimap implementation that I’ve discovered is horribly inefficient; framerate drops from a smooth 30 to a shaky 17 in the worst case when it’s active.
The algorithm in use now basically does this:
for( map.width ){
for( map.height ){
glLineWidth(LINE_WIDTH);
if(currentTile.explored) glColor4ub(currentTile.minimapR, currentTile.minimapG, currentTile.minimapB, currentTile.minimapA);
else glColor4ub(0, 0, 0, 255);
drawLine( CGPointMake(x, y), CGPointMake(x, y+LINE_WIDTH));
}
}
which gets called every frame. Even when only drawing a 30x30 subset of the tilemap, this is killing the framerate.
It was suggested to me that I create one texture for the entire map in advance, and just draw that static texture, which makes sense. However, that approach might not fully meet the requirements I’ve got to implement and it would take me a day or so learning how to do, so I want to make sure that’s what I should be doing.
The snag is that the map needs to reveal itself as the player explores it, so building one texture upfront for the entire map would require some way to mask parts of it. Can that be done somehow? The current implementation was probably designed with this feature in mind.
The alternative would be remaking the texture each time more of the map has been revealed, which is almost constantly. I have to assume that would be a lot worse than our current algorithm. Is that a reasonable assumption to make?