Pyggles Live!!!

Here's a new warm up. I decided to translate an old favorite from JavaScript & DHTML to Python & Pyglet. It's called Pyggles! (Hey, I only learned Python two weeks ago, okay?)

(log in to comment)

Comments

Looking good, and I'm impressed with your startup speed (of learning). If you haven't already, take a look at the pyglet 1.1 sprite module. It doesn't do automatic sorting by depth like you asked for, but if you can group your sprites into layers it's pretty trivial to render these in order.
Thanks! Your right. (BTW, I renamed it to Wyggles) I think I need to nab the SVN stuff if I'm going to have something decent for the competition. The sprite engine I wrote in Java 6 years ago has layers but I think there still needs to be depth sorting per layer. Why would 2D be more complicated than 3D?!!!
2D is more complicated than 3D because 3D automatically handles depth, you just have to render the sprites at the correct depth. With 2D you have to first sort your sprites by depth, and then render them onto the screen in reverse order ;)
Of course you can enable the depth buffer for a 2D application and specify depth with Z on each vertex. (In pyglet, glEnable(GL_DEPTH_TEST) and glClear(GL_DEPTH_BUFFER) each frame). Anything a 3D application can do a 2D application can do.

I assumed you were using a non-commutative blend operation (such as GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), in which case you'll need to do depth sorting (in both 2D and 3D applications). Often you can get away with a commutative blend (such as GL_SRC_ALPHA, GL_ONE) to avoid sorting.

Interesting. I'll disable sorting on the layer class I wrote last night and try that. Maybe it was doing glEnable and glClear PER FRAME that was the missing ingredient.