On Saturday, July 20, 2013 6:12:41 PM UTC+2, Ryexander wrote:
>
> I personally have tackled this problem with great success using an 
> additionally Library call rabbty.
>
> I built a numpy array of all my rabbty sprites (I even had it be multi 
> dimensional) then sliced out each layer and passed the layer array to 
> rabbty's render multiple.
>
> rabbty and pyglet are compatible (rabbty even supports using pyglet to 
> load sprites) but rabbty is a c extension and is designed to render a lot 
> of sprite extremely fast.
>
> my results were the ability to use numpy's fast array operations to both 
> slice out only the visible parts of the map to render putting a hard limit 
> on the number of tiles rendered per frame regardless of map size ((max 
> tiles visible horizontally + 1 to account for scrolling) * (max vertically 
> + 1) * number of layers) and the ability to acheave frame rates above what 
> piglet can get even will well managed vertex lists
>
> I know it's not the answer you asked for but this was my eventual solution 
> as I didn't want the tilemap to be a limiting point in my system.
>
> as a bonus it's extremely easy to manipulate the tilemap with some 
> ridicules effects because all the tiles are in a numpy array.  imagine 
> simulating an earthquake by adding a tiny back and forth tween to every 
> tile in the visible area of the map with just a few lines of code. or 
> instantly replacing every tile with a specific ID (provide you keep a 
> parallax array of the tile ID's to do masking with) with another.
> the possibilities are endless
>
>
It seems really interesting. I'll have a look at it. Thanks a lot.

The only thing that bothers me is that I won't learn what slows my code 
down :)
 

> On Friday, July 19, 2013 5:07:01 PM UTC-6, Fred wrote:
>>
>> Hello,
>>
>> I'm using pyglet to make an old-fashioned 2D RPG engine. A map is made of 
>> layers (up to 10), each layer is made of tiles (21 * 15 tiles). A map can 
>> be big (more than 100 x 100 tiles), and sometimes infinite (toric).
>>
>> The map is rendered in a single batch, each layer is attached to an 
>> OrderedGroup. 
>> A tile from a layer is attached to a sprite (in 'static' mode), but I 
>> keep only tiles that are effectively on screen (in a list). When a tile 
>> goes outside the screen, the sprite is destroyed (it's removed from the 
>> list so I suppose it's destroyed since there are no references on it 
>> anymore), and to the contrary, when a new tile comes inside the screen, I 
>> add a new sprite to the group. I've read they are slow operations, but I 
>> don't see a better way (the maps are too big to keep all the sprites).
>>
>> My problem is that I have performances issues for the biggest maps : I 
>> reach at most 5 fps, where I'd like to have 60. Event for smaller ones 
>> (only 3 layers), I get 30 - 40 fps.
>>
>> Am I doing it the wrong way (and if so, could you please point me better 
>> ideas) or is my goal clearly unreachable using Python + pyglet, and would 
>> require C++/OpenGL code ?
>>
>> Thanks in advance !
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to