1 /* 2 Pacman Arena 3 Copyright (C) 2003 Nuno Subtil 4 5 This program is free software; you can redistribute it and/or 6 modify it under the terms of the GNU General Public License 7 as published by the Free Software Foundation; either version 2 8 of the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 /* $Id: particle.h,v 1.2 2003/11/22 17:32:10 nsubtil Exp $ */ 21 22 #ifndef _PARTICLE_H 23 #define _PARTICLE_H 24 25 #define PARTICLE_STATE_DEAD 0 26 #define PARTICLE_STATE_ACTIVE 1 27 28 struct particle 29 { 30 /* particle state (dead, active, ...) */ 31 int state; 32 /* time */ 33 float time; 34 /* 3D world-space position */ 35 float position[3]; 36 /* constant direction vector */ 37 float direction[3]; 38 /* particle color */ 39 float color[3]; 40 /* speed */ 41 float speed; 42 /* gravity */ 43 float gravity; 44 }; 45 46 struct particle_src 47 { 48 /* number of particle structures */ 49 int n_particles; 50 /* particles */ 51 struct particle *particles; 52 53 /* life of each particle */ 54 float particle_life; 55 /* fade time of each particle */ 56 float particle_fade; 57 /* particle generation rate */ 58 float particle_rate; 59 /* last generation time */ 60 float last_particle_time; 61 /* particle size */ 62 float particle_size; 63 64 /* fountain position */ 65 float position[3]; 66 /* fountain speed vector */ 67 float src_speed[3]; 68 /* fountain direction */ 69 float direction[3]; 70 /* maximum direction spread */ 71 float spread; 72 /* speed */ 73 float speed; 74 /* maximum speed variation */ 75 float speed_spread; 76 /* fountain gravity */ 77 float gravity; 78 /* particle colors */ 79 float color[3]; 80 81 /* light source for particle */ 82 struct light *light_src; 83 }; 84 85 struct particle_src *particle_new_src(float life, float fade, float rate, float size, 86 float position[3], float direction[3], float src_speed[3], 87 float spread, float speed, float speed_spread, 88 float gravity, float color[4]); 89 int particle_add(struct particle_src *src); 90 void particle_src_update(struct game *game, struct particle_src *src, float delta); 91 void particle_update(struct game *game, struct particle_src *src, int particle_no, float delta); 92 void particle_free_src(struct particle_src *src); 93 int particle_src_all_dead(struct particle_src *src); 94 void particle_src_explode(struct particle_src *src, int num_particles_explosion, float max_speed); 95 #endif 96