In your opinion, how should I process to display them correctly? Like making multiple vertexArray but then, how do I draw them separately????
As I understand it, while re-calling the draw function i just redefine the previous vertex, and I just erase from screen the previous layers?
When I have to draw all of them, I will just call my drawing function for layer-0,-1,-2,...,layer-N.
tileType = m_Map[i][j][Layer]
The problem I got is that even with a color mask for each texture, while drown, tiles of inferior layers with no Tiles above them ( so they're theorically visible ) are not shown.
I'm currently working on a hexagonal tile based game and I got a little problem when it comes to layers.
It is up to you how it is done (but putting everything of the ground into one draw call every frame would be a bit of processing). If you have multiple sf::VertexArray's, you would just have multiple draw calls...
Like so:sf::VertexArray va1;
sf::VertexArray va2;
sf::VertexArray va3;
renderWindow.draw(va1);
renderWindow.draw(va2);
renderWindow.draw(va3);
In this case, va1...va3 would be the layers.
Yes. Reconstructing a sf::VertexArray every frame during the drawing isn't the best way to go about doing this, for most occasions. Make the sf::VertexArray a property of the class, and update it that way.
A possible way to do this would be (breaking down what is to be done using rough non-UML UML):Layer (inherited from sf::Drawable)
(**This is optional, whereas it would essentially be a re-implementation of sf::VertexArray, only more specific to this design by only drawing the things within the view of the parent Map)
parent : Map* (the parent map)
draw() const: void (puts each vertex within the view of the parent into the vertex array and draws it, this should probably be broken into two functions)
Map (inherited from sf::Drawable)
layers : std::array<Layer, 5> (this example specifically talks about 5 layers)
draw() const: void (draws each layer to the render target)
updateView() : void (updates the views of each)
Also, classes that are call "*Managers" represent a bad programming design. A class should generally have a single purpose. I recommend structuring out all of the components of your project on paper, and either come up with a better more specific name or break what is does into smaller classes. (see my above example for a new possible design)
Nested arrays/vectors are not very efficient. Instead, single dimensional array. An example of that can be found here (http://stackoverflow.com/questions/3613429/algorithm-to-convert-a-multi-dimensional-array-to-a-one-dimensional-array)(<this is a link, people don't seem to notice the difference in colours, apparently).
You are drawing hexagons which quads? ???
I actually know how to convert N-d arrays into a single D one, but is the difference in perfomances really that noticeable?
rendering 3 to4 times 4billion
I used a dynamic arrays for it since the map size will not change.
[...]manage Layers[...]Not manage. Manage is far too ambiguous of a word. Manage could refer to controlling the lifetime of the objects, which may not be the case.
I'm still not so used to classesNot to sound rude or anything, but get used to them. ;) They are one of the most important features of C++. Imagine if you designed a class called FordCar. And from there, you put every piece of code required for FordCar to accelerate, steer, change gears, etc. Now when you make a new class called FiatCar, you would have to reinvent the wheel (not an intentional pun), by creating all of these functions again.
(click to show/hide)