1 #include <stdlib.h>
2 #include <math.h>
3 #include <X11/Xlib.h>
4 
5 typedef struct {
6   char *control_name;
7   double cval; /* current value */
8   double dflt; /* default value */
9   double min;
10   double max;
11   double delta; /* delta to change by */
12 } Cset;
13 
14 typedef struct {
15   double x,y;   /* x and y positions, confined between 0 and 1 */
16   double xv,yv; /* and velocities */
17   int life;
18 } Particle;
19 
20 typedef struct Particle_Sys {
21   Particle *p;
22   int n_particles;
23 
24   char *loadimage;
25   /* current force system */
26   void (*frc)(struct Particle_Sys *, Particle *, Particle *);
27   /* force values */
28   Cset *cvar[4];
29 
30   int xpos, ypos; /* centre-point for explosions */
31   int follow;
32 
33   /* Region used for creation of particles */
34   int reg_xmin, reg_xmax, reg_ymin, reg_ymax;
35 
36   int start_life;
37   /* Particle system smudge factors */
38   double friction; /* particle velocity is multiplied by this each frame */
39   double xgrav, ygrav; /* x,y axis gravities */
40   double xcent, ycent; /* x,y centering tend */
41 
42   /* Booleans to turn on things */
43   int tend_to_centpt;
44   int use_friction;
45   int use_gravity;
46 } Particle_Sys;
47 
48 void psys_dec_var(Particle_Sys *psys, int vnum);
49 void psys_inc_var(Particle_Sys *psys, int vnum);
50 void psys_reset_defaults(Particle_Sys *p);
51 void psys_toggle_gravity(Particle_Sys *psys);
52 
53 
54 void psys_stick(Particle *p1, Particle *p2);
55 void psys_frc_stf(Particle_Sys *psys, Particle *p1, Particle *p2);
56 void psys_frc_ang(Particle_Sys *psys, Particle *p1, Particle *p2);
57 void psys_frc_oth(Particle_Sys *psys, Particle *p1, Particle *p2);
58 void psys_frc_gra(Particle_Sys *psys, Particle *p1, Particle *p2);
59 void psys_frc_spr(Particle_Sys *psys, Particle *p1, Particle *p2);
60 
61 /* Set particle system to use a particlar force system */
62 void psys_set_gra(Particle_Sys *psys);
63 void psys_set_ang(Particle_Sys *psys);
64 void psys_set_oth(Particle_Sys *psys);
65 void psys_set_spr(Particle_Sys *psys);
66 void psys_set_stf(Particle_Sys *psys);
67 void psys_set_rnd(Particle_Sys *psys);
68 
69 /**********************************************************************/
70 /**********************************************************************/
71 /**********************************************************************/
72 
73 void psys_set_region(Particle_Sys *psys, double xmin, double xmax, double ymin, double ymax);
74 void psys_rand_edge_starts(Particle_Sys *psys);
75 void psys_rand_burstpt(Particle_Sys *psys);
76 void psys_set_defaults(Particle_Sys *psys);
77 void psys_resetparticle(Particle_Sys *psys, Particle *d);
78 void psys_reset_all_particles(Particle_Sys *psys);
79 int psys_create_particles(Particle_Sys *psys);
80 void psys_set_spr_forces(Particle_Sys *psys, double springlen, double konstant);
81 void psys_frc_to_all(Particle_Sys *psys);
82 void psys_frc_to_lead(Particle_Sys *psys);
83 void psys_frc_to_next(Particle_Sys *psys);
84 void psys_move(Particle_Sys *psys);
85 void psys_automovep(Particle_Sys *psys);
86 
87 
88 
89