I am using a class in python (I am also using pygame in this program) but it will not allow me to call this particular method. The class is called 'enemy'. This is the problem method:
def attack(self, screen):
self.charx = self.screen.get_width()/2 - self.pic.get_width()/2
self.chary = self.screen.get_height()/2 - self.pic.get_height()/2
textbox(self.screen, self.charx - self.c.rect.x + self.rect.x, self.chary - self.c.rect.y + self.rect.y, 15, 5, True, (255, 255, 255), True, (0, 0, 0), 0, '', True, (255, 0, 0), 15*self.healthpercent)
if self.rect.colliderect(self.w.rect):
if self.agility*random.randint(1, 10) > self.c.agility*random.randint(1, 10):
self.c.health -= self.level*5
if self.agility*random.randint(1, 10) <= self.c.agility*random.randint(1, 10):
self.health -= self.w.weaponpower*self.c.strength
self.healthpercent = self.health/self.level*100
if self.health == 0:
self.dead = True
This is how I am calling it:
e = enemy(enemypics, 50, 50, 4, 3, screen, c, bgdict, w)
if e.dead == False:
e.attack(screen) #stops on this line
e.update(screen)
else:
e.die(screen, timesincelasttick)
Obviously some variable names etc are defined elsewhere, but I didn't think those bits were necessary. This is the full stack trace:
Traceback (most recent call last):
File "E:\Code\Game\Main6.py", line 119, in <module>
e.attack(screen)
TypeError: 'int' object is not callable
>>>