[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Could sprite drawing be done but a Sprite.draw function?



Hi all,

I'm pretty new to pygame (although I have good experience with python)
and this is my first message on the list. Bear with me if what I am
about to ask has been already discussed.

While working around my first program, I realised that while each
sprite has an update() function, it's drawing happens at group level,
by blitting the s.image and s.rect directly, which somehow limits this
functionality (for example making impossible to set blit flags).

I was wondering if this was a design choice, and in that case, what's
the rationale behind it.

I realise both that:

 1. Calling a sprite function is expensive
 2. I can override the group.draw method to call a sprite function

Yet it seems to me that having a sprite.update without a sprite.draw
is "inconsistent" from an API standpoint.

I did not profile the code to see how big is the performance hit
because of #1, but #2 has serious limitations as a workaround: for one,
the draw() method changes in each an all of the group classes, so if
the sprite must use a draw method, one will have to override _all_ of
the draw methods of the types of groups used in the program.

Your thoughts?
/mac