Problems with code

Zach Goscha ZTank5 at gmail.com
Mon Mar 30 12:05:34 EDT 2009


Hi,

I am trying to call an unbound method (Map.Background) but getting the following error:
 TypeError: unbound method background() must be called with Map instance as first argument (got nothing instead)

Here is some of the code(not completed) 

Thanks in Advance
- Zach


Code:

class Knight(games.Sprite):
    """ A moving knight. """
    SWORD_DELAY = 50
    sword_wait = 0
        
        
    def update(self):
        """ moving knight based on keys pressed. """

        if games.keyboard.is_pressed(games.K_w):
            self.y -= 3
            self.angle = 0
        if games.keyboard.is_pressed(games.K_s):
            self.y += 3
            self.angle = 180
        if games.keyboard.is_pressed(games.K_a):
            self.x -= 3
            self.angle = 270
        if games.keyboard.is_pressed(games.K_d):
            self.x += 3
            self.angle = 90

        if self.top > games.screen.height:
            self.bottom = 0        

        if self.bottom < 0:
            self.top = games.screen.height
            Map.background()

        if self.left > games.screen.width:
            self.right = 0

        if self.right < 0:
            self.left = games.screen.width

class Map(games.Sprite):

    def background(self):
        new_back = games.load_image("map3.jpg",
transparent = False)
        games.screen.background = new_back

        
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090330/285b5d80/attachment.html>


More information about the Python-list mailing list