Particles (PE.particles)
PE.particles.Emitter
particle emitter.
class usage:
an object in space that emits particles.
Emitter.__init__(self, texture: pygame.Surface, pos: pygame.Vector2, size=10, speed=1, life_time=1, spawn_rate=1, max_particles=20, spread_range=360, rotation=0, rot_speed=0)
function actions:
initializing the emitter.
​
parameters:
texture - the particle texture (pygame.Surface)
pos - emitter position (Vector2 like)
size - particle radius (float)
speed - particle movement speed (float)
life_time - how much time should pass until the particle being deleted (float)
spawn_rate - how many particles will spawned in a second (float)
max_particles - how many particles should stop the emitter from spawning more (int)
spread_range - the angle of spawning range (float)
rotation - the rotation of the spread range (float)
rot_speed - the rotation speed of the particles (float)
​
Emitter.show(self, workspace: pygame.Surface)
function actions:
put the particles on a surface​
​
recommended place in script:
at the main loop. (this is a tick fundction)
​
parameters:
workspace - the surface that the particles should appear on (pygame.Surface)
​
Emitter.frame(self)
function actions:
calculates next particle simulation step​
​
recommended place in script:
at the main loop. (this is a tick fundction)
​
Emitter.change_variables(self, texture=None, pos=None, size=None, speed=None, life_time=None, spawn_rate=None, max_particles=None, spread_range=None, rotation=None, rot_speed=None)
function actions:
change the emitter init parameters without creating another​
​
parameters:
texture - the particle texture (pygame.Surface)
pos - emitter position (Vector2)
size - particle radius (float)
speed - particle movement speed (float)
life_time - how much time should pass until the particle being deleted (float)
spawn_rate - how many particles will spawned in a second (float)
max_particles - how many particles should stop the emitter from spawning more (int)
spread_range - the angle of spawning range (float)
rotation - the rotation of the spread range (float)
rot_speed - the rotation speed of the particles (float)
​
​
​
PE.particles.Particle
class usage:
used by the emitter in order to store particles data
useless for self use.
Particle.__init__(self, texture:pygame.Surface, pos: pygame.Vector2, size:float, direction:int)
function actions:
store particle data​
​
parameters:
texture - the particle texture (pygame.Surface)
pos - particle position (Vector2 like)
size - particle radius (float)
direction - particle movement direction (int)
Particle.show(self, workspace: pygame.Surface)
function actions:
put particle on a surface​
​
parameters:
workspace - the surface to put the particle on, commonly used as the window (pygame.Surface)
PE.particles.rand_spread(spread_range: int, rot: int)
used by the emitter
function actions:
generate random direction in a range​
​
parameters:
spread_range - the random range (int)
rot - the range rotation (int)
​
returns:
returns a random direction in a range (int)
PE.particles.spawn_rate_sens
the resolution of float random emitter spawn
​
variable usage:
when the emitter's spawn rate is a float, it have a random chance to spawn additional particle, this variable is how this random generator accurate (the resolution grate as the spawn rate sensitivity).
​
type:
int/float(float is not recommended)
PE.particles.delta_time
variable usage:
current delta time, set by PE.events() function every frame.
​
type:
int
