A short library for easy to use particles in Pygame based on DaFluffyPotato's particle system.
Project description
ParticlePy
v1.0.1
Examples
A short library for easy to use particles in Pygame based on DaFluffyPotato's particle system.
Installation
Dependencies
- Pygame ~= 2.0.1
Pip
pip install particlepy
or
pip install git+https://github.com/grimmigerFuchs/ParticlePy.git
Manually
- Clone the repo
git clone https://github.com/grimmigerFuchs/ParticlePy.git
- Go into the directory
cd ParticlePy/
- Run
setup.py
python setup.py install
Usage
This is a short example of how to use this library. Others can be found in the examples
folder.
Note the standard FPS in the example was set to 60.
Imports
import pygame
import particlepy
import random
Needed classes
# particle system with grouped functions
particles = particlepy.ParticleSystem(remove_particles_batched=False) # particle system; argument: no batched removals
Particle creation
Circle
particles.create(particlepy.Circle(position=pygame.mouse.get_pos(), # get mouse pos
velocity=(random.uniform(0, 1) * random.choice((-1, 1)), -3), # x and y velocity
size=random.randint(2, 25), # size of particles
delta_size=random.uniform(0.035, 0.050), # decreases size every frame
color=(255, 255, 255), # rgb
alpha=255, # optional transparency
antialiasing=True)) # aa normally turned off
Rectangle
# almost same as circles but for rects aa is not an option
particles.create(particlepy.Rect(position=pygame.mouse.get_pos(),
velocity=(random.uniform(0, 1) * random.choice((-1, 1)), -3),
size=random.randint(2, 25),
delta_size=random.uniform(0.035, 0.050),
color=random.randint(210, 255),
alpha=255))
Updating positions and drawing the particles with particle systems
# update position and size
particles.update(delta_time=delta_time, gravity=0.009) # both arguments are optional; gravity pulls particles down
# draw particles
particles.draw(surface=screen) # draw particles on given surface
The shown code was taken from the example program examples/example.py
.
License
Distributed under the MIT License. See LICENSE
for more
information.
Contact
grimmigerFuchs - grimmigerfuchs@gmail.com
Project Link: https://github.com/grimmigerFuchs/Pyticles
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
particlepy-1.0.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for particlepy-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba10730efc8928251cfe1d172065face342f8a05ef17f19520bb560ea8aea5f0 |
|
MD5 | 2750fcc460d28a1c6cb5c62638b2293b |
|
BLAKE2b-256 | b3e8e1c3bcea769a5324c57ae71c13efe471f9f384e826a06aeee1db044573ab |