The project is an RPG, because I wanted to be original and not make Pong like err'body else. I realized just yesterday, "Perhaps having layers would make it prettier! :D" So I implemented it, and as of right now, I have 2 layers displaying on screen. This is fine and dandy, but the map renders realllly slowly.
This is how I currently do it:
Code: Select all
void Init(){
// Initialize the tiles
Tile** tile;
tile = new Tile*[mapWidth];
for (int x = 0; x < mapWidth; x++){
tile[x] = new Tile[mapHeight];
for (int y = 0; y < maHeight; y++){
// Set the positions of the tiles
tile[x][y].SetPos(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
}
}
void paintEvent(QPaintEvent *event){
QPainter paint (this);
for (int x = 0; x < mapWidth; x++){
for (int y = 0; y < mapHeight; y++){
tile[x][y].Render(paint, tileSheet);
}
}
}
Does anybody have a suggestion as to a better way of handling display of the tile maps with an array style like that? I'm stumped for ideas here. I just know that, say, the user makes a map 100 x 100 (in tiles), and each tile is 32 x 32 px. That would be drawing 10,000 tiles. If I have 2 + layers of that, it will get pretty slow, especially if there's a lot of stuff drawn on each layer.
So, if it makes any difference, I'm using QPainter to draw, and checking if each tile should be drawn, then drawing it if so. I'm just looking for a better approach then this, and not a linked list or stack. Unless I'm doing it wrong for one or both of those, in which case, any support in that manor would be greatly appreciated .
-- Jesse Guarascia