I'm developing an old-fashioned 2D RPG with Python + pyglet.
The map is made of several layers (up to 10), each of them consituted of squared tiles (32x32 pixels). The sprites (party characters, NPC, and some others things) are drawn between two layers (usually just before the last).
To render it, I use a single Batch, with many OrderedGroups : one group per layer, and a group per sprite.
The problem with sprites is that they must be rendered in the decreasing order of their y value, so groups are arranged as follow (let's suppose there's 3 layers in the map, and that 2 sprites must be drawn just before the last) :
g = OrderedGroup(0) : first layer
g = OrderedGroup(1) : second layer
g = OrderedGroup(2) : empty, serves as a base for the following :
OrderedGroup(0, parent = g) : the highest sprite
OrderedGroup(1, parent = g) : the lowest sprite
g = OrderedGroup(3) : the third layer
When I add layer-sprites to the batch, I specify that they are static. When I add party sprites, they are 'dynamic'.
So my first question : since they all belong to the same batch, isn't it contradictory ? (said differently : is 'static' or 'dynamic' a property of the sprite object, or of the batch ?) (note : I precise that I have really few knowledge about OpenGL and have no idea how batch and groups are implemented)
For the time being, performance is correct (I want 60 fps, and I have them up to 8 moving sprites), but perfomance decreases quickly with more than 8 moving sprites (which should not happen in the final game, but I'd like my engine to be the most efficient possible without translating parts in C/ASM).
So my second question : is the strategy I choose (use batch, and as few as possible) the good one ?
Thanks in advance for answers
No replies to this topic