Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_particles.c File Reference

particle function file for SantaHack 2012 More...

#include "nilorea/n_particles.h"
#include "math.h"
+ Include dependency graph for n_particles.c:

Go to the source code of this file.

Functions

static ALLEGRO_COLOR _color_lerp (ALLEGRO_COLOR a, ALLEGRO_COLOR b, float t)
 helper to linearly interpolate a color
 
static void _emitter_shape_offset (const PARTICLE_EMITTER *em, double *out_x, double *out_y)
 compute shape-offset spawn position for an emitter
 
static double _particle_rand_range (double vmin, double vmax)
 helper to generate a random double between min and max
 
static int _particle_rand_range_i (int imin, int imax)
 helper to generate a random int between min and max (inclusive)
 
PARTICLE_EMITTERadd_emitter (PARTICLE_SYSTEM *psys)
 add a new emitter to the particle system
 
int add_particle (PARTICLE_SYSTEM *psys, int spr, int mode, int lifetime, int size, ALLEGRO_COLOR color, PHYSICS object)
 add a particle to a particle system
 
int add_particle_at (PARTICLE_SYSTEM *psys, int spr, int mode, double px, double py, double pz, int lifetime, int size_start, int size_end, ALLEGRO_COLOR color_start, ALLEGRO_COLOR color_end, double vx, double vy, double vz, double ax, double ay, double az)
 add a particle at an absolute world position (not relative to psys->source)
 
int add_particle_ex (PARTICLE_SYSTEM *psys, int spr, int mode, int off_x, int off_y, int lifetime, int size, ALLEGRO_COLOR color, double vx, double vy, double vz, double ax, double ay, double az)
 add a particle to a particle system, all in line version (you have to set the PHYSICS object parameter in the function parameter instead of providing a PHYSICS object)
 
int draw_particle (PARTICLE_SYSTEM *psys, double xpos, double ypos, int w, int h, double range)
 draw particles of a particle system
 
int free_emitters (PARTICLE_SYSTEM *psys)
 free all emitters in the particle system
 
int free_particle_system (PARTICLE_SYSTEM **psys)
 destroy and free a particle system
 
int init_particle_system (PARTICLE_SYSTEM **psys, int max, double x, double y, double z, int max_sprites)
 initialize a particle system
 
int manage_particle (PARTICLE_SYSTEM *psys)
 update particles positions using particle system internal timer
 
int manage_particle_ex (PARTICLE_SYSTEM *psys, double delta_t)
 update particles positions using provided delta time
 
int move_particles (PARTICLE_SYSTEM *psys, double vx, double vy, double vz)
 move all particles of a particle system by a given offset
 
int remove_emitter (PARTICLE_SYSTEM *psys, const PARTICLE_EMITTER *em)
 remove an emitter from the particle system and free it
 

Detailed Description

particle function file for SantaHack 2012

Author
Castagnier Mickael aka Gull Ra Driel
Version
1.0
Date
20/12/2012

Definition in file n_particles.c.

Function Documentation

◆ _color_lerp()

static ALLEGRO_COLOR _color_lerp ( ALLEGRO_COLOR  a,
ALLEGRO_COLOR  b,
float  t 
)
static

helper to linearly interpolate a color

Parameters
astart color
bend color
tinterpolation factor [0..1]
Returns
interpolated color

Definition at line 225 of file n_particles.c.

Referenced by manage_particle_ex().

+ Here is the caller graph for this function:

◆ _emitter_shape_offset()

static void _emitter_shape_offset ( const PARTICLE_EMITTER em,
double *  out_x,
double *  out_y 
)
static

compute shape-offset spawn position for an emitter

Parameters
emthe emitter
out_xoutput x offset
out_youtput y offset

Definition at line 157 of file n_particles.c.

References PARTICLE_EMITTER::shape, PARTICLE_EMITTER::shape_h, PARTICLE_EMITTER::shape_rotation, and PARTICLE_EMITTER::shape_w.

Referenced by manage_particle_ex().

+ Here is the caller graph for this function:

◆ _particle_rand_range()

static double _particle_rand_range ( double  vmin,
double  vmax 
)
static

helper to generate a random double between min and max

Parameters
vminminimum value
vmaxmaximum value
Returns
random value in [vmin, vmax]

Definition at line 202 of file n_particles.c.

Referenced by manage_particle_ex().

+ Here is the caller graph for this function:

◆ _particle_rand_range_i()

static int _particle_rand_range_i ( int  imin,
int  imax 
)
static

helper to generate a random int between min and max (inclusive)

Parameters
iminminimum value
imaxmaximum value
Returns
random value in [imin, imax]

Definition at line 213 of file n_particles.c.

Referenced by manage_particle_ex().

+ Here is the caller graph for this function: