Pygame Particles Tutorial - Over 20K Particles At 60FPS
Vložit
- čas přidán 21. 04. 2023
- In this video we will make a particle system in pygame-ce which is capable of handling over 20,000 particles at a smooth framerate. We will then modify the particle system so it acts like rain.
Code here: github.com/bigwhoopgames/yout...
Join the discord here:
/ discord - Hry
very nice - thanks for the pygame-ce tip, i wasn't aware of that option
subbed
Downloaded the code and now I can't stop experimenting with all the values . These patterns when generating them in the middle of the screen with random direction (and reflection on all sides) are so beautiful. Thanks a lot for providing the code.
Enjoy!
Awesome tutorial, and glad to hear you use pygame ce!
Glad you like it!
@@bigwhoopgames I'm working on a framework/ function collection that makes pygame game dev 10 to 100 times faster. Now I feel inspired by this to add a particle system to it! :)
this channel is a gold mine
Thanks, let me know what else you'd like to see.
@@bigwhoopgames im looking to learn pygame and stumbled upon your channel, keep up the great work 💪💪
Will do.
this is pretty crazy
Thanks!
i am confused why have you added the the __len__ function in particle manger as the inbuilt python len do the same job
Adding the __len__ function allows someone to get to call len(particleman) instead of len(particleman.particles) assuming particleman is a ParticleManager.
Its not super needed but helps clean up the code a bit.
I thought everything f_ was just for floats? Any specific reason why it's faster?
I assume you are referring to the fblits function which is short for 'fast blits' as opposed to an frect which is a rect but with floats.
From the docs: "Note This method only accepts a sequence of (source, dest) pairs and a single special_flags value that's applied to all surfaces drawn. This allows faster iteration over the sequence and better performance over blits(). Further optimizations are applied if blit_sequence is a list or a tuple (using one of them is recommended)."
Basically they simplified the internals of the function to streamline its execution.
i get this running the downloaded code """AttributeError: 'pygame.surface.Surface' object has no attribute 'fblits'. Did you mean: 'blits'?""" but if i change line 68 fblits to just blits it does ....? why ? btw it is so awesome thanks
Are you using pygame-ce? pygame-ce is an updated version of pygame that is more modern and has more features.
Run:
pip uninstall pygame
pip install pygame-ce
then try.