Skip to main content

A short library for easy to use particles in Pygame.

Project description

ParticlePy

v1.0.4-beta

Documentation Status PyPi Version

ExamplesDocumentationPyPi

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

Installation

Dependencies

  • pygame

  • setuptools

  • Sphinx

  • sphinx_rtd_theme

Versions

Latest

Pip

pip install --upgrade particlepy
# or
pip install --upgrade git+https://github.com/grimmigerFuchs/ParticlePy.git

Git

git clone https://github.com/grimmigerFuchs/ParticlePy.git
cd ParticlePy/
pip install -r requirements.txt
python3 setup.py install

Usage

This is a short example of how to use this library. Examples can be found in the examples folder.

#!/usr/bin/env python3
# example.py

import pygame
import particlepy
import sys
import time
import random

pygame.init()

# pygame config
SIZE = 800, 800
screen = pygame.display.set_mode(SIZE)
pygame.display.set_caption("ParticlePy example program")
pygame.mouse.set_visible(False)

# timing
clock = pygame.time.Clock()
FPS = 60

# delta time
old_time = time.time()
delta_time = 0

# particle system to manage particles
particle_system = particlepy.particle.ParticleSystem()

# main loop
while True:
    # quit window
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                pygame.quit()
                sys.exit()

    # delta time
    now = time.time()
    delta_time = now - old_time
    old_time = now

    # get mouse position
    mouse_pos = pygame.mouse.get_pos()

    for _ in range(5):
        particle_system.emit(
            particlepy.particle.Particle(shape=particlepy.shape.Rect(radius=16,
                                                                     angle=random.randint(0, 360),
                                                                     color=(3, 80, 111),
                                                                     alpha=255),
                                         position=mouse_pos,
                                         velocity=(random.uniform(-150, 150), random.uniform(-150, 150)),
                                         delta_radius=0.2))

    # update particle properties
    particle_system.update(delta_time=delta_time)

    # color manipulation
    for particle in particle_system.particles:
        particle.shape.color = particlepy.math.fade_color(particle=particle,
                                                          color=(83, 150, 181),
                                                          progress=particle.inverted_progress)

    # render shapes
    particle_system.make_shape()

    # post shape creation manipulation
    for particle in particle_system.particles:
        particle.shape.angle += 5

    # render particles
    particle_system.render(surface=screen)

    # update display
    pygame.display.update()
    screen.fill((13, 17, 23))
    clock.tick(FPS)

Gif of particle simulation

License

Distributed under the MIT License. See LICENSE for more information.

Contact

grimmigerFuchs - grimmigerfuchs@gmail.com
Github Repository: https://github.com/grimmigerFuchs/ParticlePy
PyPi Project: https://pypi.org/project/particlepy/

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.4b0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

particlepy-1.0.4b0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file particlepy-1.0.4b0.tar.gz.

File metadata

  • Download URL: particlepy-1.0.4b0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

File hashes

Hashes for particlepy-1.0.4b0.tar.gz
Algorithm Hash digest
SHA256 b626782c73a3a9a7265cb207006e9aee11230d2eb53f89661b00d844058d4493
MD5 3cbe3e25f93173c13725d8877026cb87
BLAKE2b-256 ad59cdc40bf55d21395c19dfb38e5b1098b636d5025e21b91ff5ce49f0191c27

See more details on using hashes here.

File details

Details for the file particlepy-1.0.4b0-py3-none-any.whl.

File metadata

  • Download URL: particlepy-1.0.4b0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

File hashes

Hashes for particlepy-1.0.4b0-py3-none-any.whl
Algorithm Hash digest
SHA256 978f69713393bd5fee20fea6c750a813dab3ca5df327e561cabcb123393c5645
MD5 769fd3ff5111d713684b95e6ed78060e
BLAKE2b-256 42e59e61906d3fd1b6ebffc8f21b4261f0eec70027abd6936360c65e2a21b5e0

See more details on using hashes here.

Supported by

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