Skip to main content
edited tags
Link
Source Link

Array of map data

I'm looking for your thoughts on the best way to store map data.

I need to store data for territory ownership for each pixel on the map. The data for each pixel is as such:

Player 1 points: 24
Player 2 points: 118
Player 3 points: 78

Currently I'm testing by using an array int[width][height][3] to store the points.

I'm then looping through it every update and re-rendering depending on the points.

for (int i=0; i < screenWidth; i++) {
    for (int j=0; j < screenHeight; j++) {
        //Do stuff with array[i][j][0]
        //Do stuff with array[i][j][1]
        //Do stuff with array[i][j][2]
    }
}

Iterating through a [800][600][3] array each render is expensive.

What is a better way to go about this?