Documentaion#

Containers#

class pygame_particles.container.ParticleContainer(*particles)#

Object that stores a list of particles and has a couple of features to make easier working with particles

add(particle: Particle)#

Add particle in the container :param particle: particle object

copy_particle(particle: Particle)#

Creates a copy of particle, so you can use the same particle and it won’t affect them

draw(screen: Surface) None#

Updates, draws and deletes dead particles

Particles#

class pygame_particles.particle.State#

Particle’s states

Parameters:
  • alive – 0

  • fading – 1

  • dead – 2

class pygame_particles.particle.Particle(center_x: int, center_y: int, objects_count: int = 10, life_seconds: float = None, fade_seconds: float = None, life_iterations: int = None, fade_iterations: int = None, color: ~pygame.color.Color | ~typing.Callable = 'white', size: int | float | tuple[typing.Union[int, float], typing.Union[int, float]] = 3, speed: int | float | tuple[typing.Union[int, float], typing.Union[int, float]] = 1, rotate_angle: int | float | tuple[typing.Union[int, float], typing.Union[int, float]] = 0, width: int = 0, shape_cls: type = <class 'pygame_particles.shape.Square'>)#

A class representing Particle group object.

Parameters:
  • shape_cls – Particle’s shape class

  • center_x – X center coordinate position

  • center_y – Y center coordinate position

  • objects_count – Count of particle parts

  • life_seconds – After that amount of seconds particle will turn into fading

  • fade_seconds – After that amount of seconds particle will turn into dead

  • life_iterations – After that amount of iterations particle will turn into fading

  • fade_iterations – After that amount of iterations particle will turn into dead

  • color – Default pygame color or a function, that takes particle and shape object and returns color

  • size – Object size range

  • speed – Move speed range

  • rotate_angle – Rotate angle range

  • width – Pygame drawing width, 0 = filled

property percent_completed#

Returns current complete percent [0; 100]

is_dead()#

Check if particle is dead

update()#

One particle update iteration

draw(screen)#

Draw particle on the screen

Shapes#

class pygame_particles.shape.Point(x: float, y: float)#

A class representing point in coordinates

move(move: Point) None#

Move point

Parameters:

move – Move vector

rotate(center: Point, radians: float) None#

Rotate point

Parameters:
  • center – Center point

  • radians – Rotate angle in radians

class pygame_particles.shape.Shape(center: Point, points: list[tuple[int, int]], speed: int)#

A class representing Shape base object. Used to generate, rotate and move groups of points

rotate(angle: int = 0) None#

Rotates the shape around the center by the specified number of degrees

Parameters:

angle – angle to rotate point in degrees

move() None#

Move shape with it’s speed and destination

draw(screen: Surface, color: Color, width: int) None#

Draw shape’s points on the screen

Parameters:
  • screen – Surface, where the particles will be drawn

  • color – Fill color

class pygame_particles.shape.RegularPolygon(center: Point, radius: float, speed: float, vertices_count: int)#

Represents a generated shape, which has equal angles and sides

class pygame_particles.shape.Pentagon(center: Point, radius: float, speed: float)#

Pentagon shape

class pygame_particles.shape.Square(center: Point, radius: float, speed: float)#

Square shape

class pygame_particles.shape.Triangle(center: Point, radius: float, speed: float)#

Triangle shape

class pygame_particles.shape.Line(center: Point, radius: float, speed: float)#

Line shape

draw(screen: Surface, color: Color, width: int) None#

Draw shape’s points on the screen

Parameters:
  • screen – Surface, where the particles will be drawn

  • color – Fill color

class pygame_particles.shape.Circle(center: Point, radius: float, speed: float)#

Circle shape

rotate(angle: int = 0) None#

Does nothing, because rotated circle is the same circle

draw(screen: Surface, color: Color, width: int) None#

Draw shape’s points on the screen

Parameters:
  • screen – Surface, where the particles will be drawn

  • color – Fill color