Skip to main content

A short library for easy to use particles in Pygame based on DaFluffyPotato's particle system.

Project description

ParticlePy

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

  1. Clone the repo
     git clone https://github.com/grimmigerFuchs/ParticlePy.git
    
  2. Go into the directory
    cd ParticlePy/
    
  3. 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 as par
import random

Needed classes

# particle system with grouped functions
particles = par.particle.ParticleSystem(remove_particles_batched=False)  # particle system; argument: no batched removals

Particle creation

Circle

particles.create(par.particle.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(par.particle.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.

Gif of example program being executed

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


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.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

particlepy-1.0.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page