0

I can call my class only one time. My code is:

class fish:
    def __init__(self, x, y, image, speed):
        self.x = x
        self.y = y
        self.image = image
        self.speed = speed
    def be(self):
        screen.blit(self.image, (self.x, self.y))
        self.x -= self.speed
        if boot.x+36 > self.x and boot.x < self.x+5:
            if boot.y+34 > self.y and boot.y < self.y+5:
                boot.live -= 1
                boot.x = 100
                boot.y = 460
fishes = []
fishes.append(fish(900, 300, fish_1, 1))

And when I call 'fish' object inside or outside the game loop(fishes.append(fish(900, 300, fish_1, 1)) I got Error:

TypeError: 'fish' object is not callable
2
  • 2
    you define a fish class but somewhere else you create an object with the same name. Rename the class to Fish, and change the contructor call to Fish(900, 300, fish_1, 1) Commented Apr 27, 2014 at 21:31
  • @BartlomiejLewandowski You should post your comment as answer. Commented Apr 28, 2014 at 14:36

1 Answer 1

1

My first guess is that you have a fish variable somewhere down in your code. Rename the class to Fish as well as the constructor call to Fish(900, 300, fish_1, 1) and it should be fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.