Jan-25-2022, 05:53 PM
(This post was last modified: Jan-25-2022, 05:53 PM by deanhystad.)
self.body can only reference one Body object, so self.body is only the last Body sprite.
The real problem is this code in Body.
To fix the problem you need to change how Body works. If it is only a single sprite it will have to know what index to use from the position list and it only updates itself. No "for pos in self.pos_list".
for pos in BODY_LIST: self.body = Body(self,pos[0],pos[1])If you wanted all the Body sprites you could do something like this:
self.body = [Body(self, x, y) for x, y in POS_LIST[1:-1]]But I don't think this matters because you don't ever use self.body, you use self.all_sprites.
The real problem is this code in Body.
def update(self): self.pos_list=POS_LIST[1:-1] self.movement() def movement(self): if self.game.head.move != [0, 0]: # Indenting should always be 4 spaces, never 1 for pos in self.pos_list: self.rect = pos[0]*10,pos[1]*10 print(self.pos_list)If there are 3 positions in self.pos_list this code moves the same Body sprite 3 times. If you have 3 Body sprites all three are moved 3 times TO THE SAME FINAL POSITION (self.pos_list[-1]). That is why it looks like all but one of the Body sprites have disappeared, they are all sitting on top of each other.
To fix the problem you need to change how Body works. If it is only a single sprite it will have to know what index to use from the position list and it only updates itself. No "for pos in self.pos_list".