Jul-05-2022, 03:46 PM
(Jul-05-2022, 01:29 AM)Windspar Wrote: First I would not use a keyword to store variables. _dir over dir.
Second print self.pos, self.dir out during update. Make sure data is right.
Other improvements.
pygame.Vector2 where made for this. Understanding the basic we take care of a lot math. They are always floats.
vector = pygame.Vector2() vector.from_polar((1, angle))To give more control over random. Create different list. Then use random choice.
explosion_data = [list(range(1, 30)), list(range(32, 60))] # in explosion for particle in explosion_data: angle = random.choice(particle) vector = pygame.Vector2() vector.from_polar((1, angle))pygame.sprite.Spirte and pygame.sprite.Group can handle your particles. They are a built in framework. They also work faster. I give example later.
For some reason, I thought pygame groups were more resource intensive, I'll certainly change that. The .pos I use is already a pygame vector2, as is vec(), I just imported it as vec for brevity. I also really like the idea of storing the random data as a list rather than calculating it a million times.
I'll implement your suggestions later today and see what I find. Thank you.