Sunday, May 13, 2012

Ah-ha!

I've got a basic tile grid working under pyglet!  Now we are so happy, we do the dance of joy.

Pygame, although easy to use, has always been a performance bottleneck for the game because it's built on SDL and does its drawing in software.  Pyglet is a lot more closely coupled with OpenGL.

Currently, a game frame is drawn in three steps:
- Background layer/gasses
- Fluids/stone/other objects
- Sprites

My idea is to separate these things out into sprite batches and vertex lists in pyglet:
- Background layer/gases: vertex list
- Fluids: vertex list
- Stone and other objects: sprite batch
- Player and other objects: sprite batch

Fluids particularly have been something I've worried about; I stopped using tiles for those in Pygame some time back due to the lack of flexibility.  Fortunately the polygonal shapes I've been using in Pygame look like they map to pyglet fairly nicely.

What is more, switching to pyglet will make it easier to use the JIT compiler of Psyco's successor, PyPy, to get around the speed limitation imposed by Python's interpreted nature.

No comments:

Post a Comment