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

Re: [pygame] RenderUpdate changes in pygame 1.7?



On 10/8/05, Luke Miller <dodgyville@xxxxxxxxx> wrote:
Hello!

In pygame 1.6, I have a collection of sprites in a RenderUpdate group,
and my code looks like this:

for i in myCollection:
   blah

Now, in pygame 1.7 I get an error when this code is running.
typeerror: iteration over non-sequence


FWIW, I have a RenderUpdates subclass in a project that needed a little tweaking after changing to 1.7.  In my case, I'm maintaining a parallel list of sprites in self.monsterlist, used to track y-order (in particular, to pinpoint which one is lowest on the screen).

the old __init__ method:
    def __init__(self, monsterblock):
        pygame.sprite.RenderUpdates.__init__(self)
        self.monsterlist = []
        self.monsterblock = monsterblock
        self.explosionsound = load_sound('zap.wav')
        self.updatebottommonster()

After moving to 1.7, this started giving me an error;  unfortunately I don't rememer exactly where, or what the error was, but in any case I was able to eliminate it by initializing my parallel list first and passing it to the superclass's __init__ method, like tshi:

new __init__ method:
    def __init__(self, monsterblock):
        self.monsterlist = []
        self.monsterblock = monsterblock
        pygame.sprite.RenderUpdates.__init__(self, self.monsterlist)
        self.explosionsound = load_sound('zap.wav')
        self.updatebottommonster()

I'm too tired to quite parse if this applies to your situation, but it popped into my head when Rene mentioned subclassing RenderUpdates.

--
// jack
// http://www.nuthole.com