I am trying to make my enemy bullets attack the player but its attacking way to fast I dont know why VIDEO my enemy bullets class
# enemys bulletsksud = pygame.image.load("heart.png")class Boolss(object):def __init__(self, x, y,color, xspeed, yspeed):self.x = xself.y = yself.xspeed = xspeedself.yspeed = yspeedself.ksud = pygame.image.load("heart.png")self.hitbox = self.ksud.get_rect()self.rect = self.ksud.get_rect()self.rect.topleft = (self.x,self.y)self.color = colorself.hitbox = (self.x + 57, self.y + 33, 29, 52) # NEWdef draw(self, window):self.rect.topleft = (self.x,self.y)player_rect = self.ksud.get_rect(center = self.rect.center) player_rect.centerx += 0 # 10 is just an exampleplayer_rect.centery += 0 # 15 is just an examplewindow.blit(self.ksud, player_rect)self.hitbox = (self.x + 97, self.y + 33, 10, 10) # NEWwindow.blit(self.ksud,self.rect)
this is where it appends bullet like attack the player
for shootss in shootsright:shootss.x += shootss.xspeedshootss.y += shootss.yspeedif shootss.x > 500 or shootss.x < 0 or shootss.y > 500 or shootss.y < 0:shootsright.pop(shootsright.index(shootss))if len(shootsright) < 1:start_x = round(enemyshoots1.x+enemyshoots1.width-107)start_y = round(enemyshoots1.y + enemyshoots1.height-50)target_x = playerman.x+playerman.width//2target_y = playerman.y+playerman.width//2dir_x, dir_y = target_x - start_x, target_y - start_ydistance = math.sqrt(dir_x**2 + dir_y**2)if distance > 0:shootsright.append(Boolss(start_x,start_y,(0,0,0),dir_x, dir_y))#------------------------------------------------------------------------------