Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[pyglet] Sprites on a tiled map : am I doing it the right way ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Tryphon   Members   -  Reputation: 107

Like
0Likes
Like

Posted 14 July 2012 - 01:05 PM

Hi,

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[0] = OrderedGroup(0) : first layer
g[1] = OrderedGroup(1) : second layer

g[2] = OrderedGroup(2) : empty, serves as a base for the following :
OrderedGroup(0, parent = g[2]) : the highest sprite
OrderedGroup(1, parent = g[2]) : the lowest sprite

g[3] = 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

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS