So i'm trying to shoot a bullet. the idea is to create a list with the variables needed to create and bullet instance and add that list to a list. then i create a bullet instance from the last item in the list that contains lists. sadly i got the "TypeError: 'tuple' object is not callable" for the line where i try to create a new bullet instance. i hope you can help me, the variable names should be self explaining.
def shoot(self):
if self.bullets_isshot == True:
self.m_x, self.m_y = pygame.mouse.get_pos()
self.bullets_new_bullet = (self.m_x, self.m_y, self.cords_x, self.cords_y)
self.bullets_list.append(self.bullets_new_bullet)
for bullet in self.bullets_list:
if bullet == self.bullets_list[-1]:
new_bullet = bullet(bullet[0], bullet[1], bullet[2], bullet[3])
self.bullets_isshot = False
and in case you need it the bullet init method:
def __init__(self, target_x, target_y, player_x, player_y):
#var img, cords
self.img = fast_load_img('/data/img/bullets/fireball.png')
self.width = 128
self.height = self.width
self.x = player_x
self.y = player_y
self.target_x = target_x
self.target_y = target_y
self.d_x = self.target_x - self.x
self.d_y = self.target_y - self.y
#var vel, angle
self.vel = 5
self.angle = math.atan2(self.d_x, self.d_y)
self.x_change = self.vel * math.cos(self.angle)
self.y_change = self.vel * math.sin(self.angle)
listoftuple, but you're trying to invoke/call the tuple which is an invalid action. You're not actually instantiating the class