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

[pygame] Problem with get_rect()



Hello, my name is Ariel.  I've been on the list for awhile, but I
neither had a problem, a solution, nor a game to announce so I've
refrained so far from sending anything.  Course now I have a problem
:p

I've been working on a game of mine called Runtling and I've ran into
a little problem with pygame.Surface.get_rect()  It says in the pygame
documentation that get_rect takes keyword arguments.  However I've ran
into error saying that it doesn't

The error is as follows:
Traceback (most recent call last):
  File "C:\Python\Runtling\Runtling.py", line 83, in -toplevel-
    if __name__ == "__main__": main()
  File "C:\Python\Runtling\Runtling.py", line 68, in main
    rect = i.rect()
  File "C:\Python\Runtling\Objects.py", line 77, in rect
    return self.ani.image().get_rect(center=self.pos)
TypeError: get_rect() takes no keyword arguments

the relavent classes:
class Widget:
    def __init__(self, animation, position, surface):
        self.ani, self.pos, self.sur = animation, position, surface
    def rect(self):
        return self.ani.image().get_rect(center=self.pos)##This is line 77
    def update(self):
        surface.blit(self.ani.update(), self.rect())

class Animation:
    def __init__(self, frames):
        self.images = frames
        self.ticks = 0
        self.repeated = False
    def update(self):
        self.ticks += 1
        leng = len(self.images)
        if self.ticks > leng * F_RATE: 
            self.ticks = 0
            self.repeated = True
        return self.images[self.ticks / F_RATE]
    def image(self):
        return self.images[self.ticks / F_RATE]
    def reset(self):
        self.ticks = 0
        self.repeated = False

-- 

Always chilling, never caring