creating Creating a lot of objects in a tilebasedtile-based game
But I do have a specific part I'd like you to review. In my Cell
class, each object represents a map tile with informations like tileID
(texture to render), and later attributes like "hasPower, water, ..."
In my Cell class, each object represents a map tile with informations like tileID (texture to render), and later attributes like "hasPower, water, ..."
ItIt is quite complex and has a lot of member functions. My game is a SimCity 2000 clone and tiles can be elevated. so a cell must check its surrounding tiles if they're elevated, and if so draw a different texture(tileIDtileID
) according to it'sits neighbors elevation or even raise / lower itself.
The rendering is also done in the CellCell
class because the sprite object must know its ISO coordinates (including the height) which is known per cell object.
I could rewrite my code, so that the rendering is done in the vectorMatrixvectorMatrix
class (in a loop that iterates over all cells in the vector, gets the cell's heigtheight, sets the sprites isocoordinates, and then calls the sprites render()render()
function), but I've tried that and it makes no performance difference.
I found this article
But but I don't understand if this is applicable for my use-case or if that's a different story.
Hope you can help me improve my code, as this is quite a bottleneck...
I've added more information and hopefully it's enough, if not please let me know!
creating a lot of objects in a tilebased game
But I do have a specific part I'd like you to review.
In my Cell class, each object represents a map tile with informations like tileID (texture to render), and later attributes like "hasPower, water, ..." It is quite complex and has a lot of member functions. My game is a SimCity 2000 clone and tiles can be elevated. so a cell must check its surrounding tiles if they're elevated, and if so draw a different texture(tileID) according to it's neighbors elevation or even raise / lower itself.
The rendering is also done in the Cell class because the sprite object must know its ISO coordinates (including the height) which is known per cell object.
I could rewrite my code, so that the rendering is done in the vectorMatrix class (in a loop that iterates over all cells in the vector, gets the cell's heigt, sets the sprites isocoordinates, and then calls the sprites render() function), but I've tried that and it makes no performance difference.
I found this article
But I don't understand if this is applicable for my use-case or if that's a different story.
Hope you can help me improve my code, as this is quite a bottleneck...
I've added more information and hopefully it's enough, if not please let me know!
Creating a lot of objects in a tile-based game
But I do have a specific part I'd like you to review. In my Cell
class, each object represents a map tile with informations like tileID
(texture to render), and later attributes like "hasPower, water, ..."
It is quite complex and has a lot of member functions. My game is a SimCity 2000 clone and tiles can be elevated. so a cell must check its surrounding tiles if they're elevated, and if so draw a different texture(tileID
) according to its neighbors elevation or even raise / lower itself.
The rendering is also done in the Cell
class because the sprite object must know its ISO coordinates (including the height) which is known per cell object.
I could rewrite my code, so that the rendering is done in the vectorMatrix
class (in a loop that iterates over all cells in the vector, gets the cell's height, sets the sprites isocoordinates, and then calls the sprites render()
function), but I've tried that and it makes no performance difference.
I found this article but I don't understand if this is applicable for my use-case or if that's a different story.
- 11.7k
- 19
- 40
In my Cell class, each object represents a map tile with informations like tileID (texture to render), and later attributes like "hasPower, water, ..." It is quite complex and has a lot of member functions. My game is a SimCity 2000 clone and tiles can be elevated. so a cell must check it'sits surrounding tiles if they're elevated, and if so draw a differenddifferent texture(tileID) according to it's neighbors elevation or even raisraise / lower itself.
The rendering is also done in the Cell class because the sprite object must know it'sits ISO coordinates (including the height) which is known per cell object.
Cell.hxx #Cell.hxx
Cell.cxx #Cell.cxx
In my Cell class, each object represents a map tile with informations like tileID (texture to render), and later attributes like "hasPower, water, ..." It is quite complex and has a lot of member functions. My game is a SimCity 2000 clone and tiles can be elevated. so a cell must check it's surrounding tiles if they're elevated, and if so draw a differend texture(tileID) according to it's neighbors elevation or even rais / lower itself.
The rendering is also done in the Cell class because the sprite object must know it's ISO coordinates (including the height) which is known per cell object.
Cell.hxx
Cell.cxx
In my Cell class, each object represents a map tile with informations like tileID (texture to render), and later attributes like "hasPower, water, ..." It is quite complex and has a lot of member functions. My game is a SimCity 2000 clone and tiles can be elevated. so a cell must check its surrounding tiles if they're elevated, and if so draw a different texture(tileID) according to it's neighbors elevation or even raise / lower itself.
The rendering is also done in the Cell class because the sprite object must know its ISO coordinates (including the height) which is known per cell object.
#Cell.hxx
#Cell.cxx
Basically I'd really appreciate if someone with experience could review my code and point out weak points since I'm not an experienced C+++C++ dev.
Basically I'd really appreciate if someone with experience could review my code and point out weak points since I'm not an experienced C+++ dev.
Basically I'd really appreciate if someone with experience could review my code and point out weak points since I'm not an experienced C++ dev.
- 29.5k
- 16
- 45
- 201