Mar-08-2020, 11:44 PM
Its a recursive function that is bottlenecking your code. You are creating objects that create more objects themselves.
So i understand the concept of Boss2 class adding Boss_body_seg objects to add to increase its length, but i dont understand why you are creating objects and not storing them in Boss_body_seg of itself? So if i comment out this is stops dragging.
So i understand the concept of Boss2 class adding Boss_body_seg objects to add to increase its length, but i dont understand why you are creating objects and not storing them in Boss_body_seg of itself? So if i comment out this is stops dragging.
class Boss_body_seg(pg.sprite.Sprite): def __init__(self, prev_seg, game, num): self.groups = game.boss_group self._layer = prev_seg._layer - 1 pg.sprite.Sprite.__init__(self, self.groups) self.game = game self.prev_seg = prev_seg self.image = self.game.boss2_body self.rect = self.image.get_rect() self.integretty = 200 self.pos = self.prev_seg.prev_pos self.num = num - 1 self.direction = self.prev_seg.direction self.last_update = pg.time.get_ticks() self.frame_rate = 120 self.frame = 0 def update(self, game, dt): #if self.frame == 10 and self.num > 0: # Boss_body_seg(self, self.game, self.num) now = pg.time.get_ticks() ...