Map Editor performance question

I’m working on a 2D tile-based map editor and I have a question about how best to manage the tile images. If, for example, I have a 1,000 x 1,000 tile map, what is the best way to display the image in the window so it can be updated quickly?

I have a TileMap class which stores the tile information, and my first thought was to combine the tiles into one image whenever the map is updated. But upon further thinking, I imagined that a map with a million tiles might take a long time to do that so I was curious if there was a better way to achieve this. Perhaps by only making the part of the map that is currently in the window? And if that is the case, how would this be done?

Another thought: Is there a way to have one image like I originally thought, but to just update that image whenever a cell is changed?

I’m just looking for options with how to procede, so any help is greatly appreciated :slight_smile:

The way i would do it would be to draw all the tiles relative to a rectangle and just move that rectangle about

To make it only draw stuff on screen I find a point on the screen and then find the points potition in tiles, then i take some away from it
upperX = pointXInTiles - 14
upperY = pointYInTiles - 14

Now your for loops dont have to run through every tile for example

20 being the width of the screen in tiles
for (int i = upperViewY; i < (20 + upperViewY); i++) {
for (int p = upperViewX; p < (20 + upperViewX); p++) {
//Do stuff like paint
}
}

This maybe? If you have enough knowledge of OpenGL, it will work very well (just look at that frame rate!).

Anyway, start with what Embedded said, and see if it gives you satisfying performance.