Store user data in $HOME
[kball.git] / include / partmang.h
blob6f6075fe7e5a42188135aac6810c00013b3d10eb
1 // -----------------------------------------------
2 // partmang.h
3 // -----------------------------------------------
4 // Particle manager, to control particles in the game
5 // Also, implementation of base particle
6 // -----------------------------------------------
7 // Developed By Kronoman - Copyright (c) 2004
8 // In loving memory of my father
9 // -----------------------------------------------
11 #ifndef PARTMANG_H
12 #define PARTMANG_H
14 #include <allegro.h>
16 #include <list> // STL container for the particles (yeah, sue me, I'm not doing my own linked list :P)
17 #include <iterator>
18 using namespace std;
20 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21 // The base particle, a dot
22 // This particle must be used as base
23 // for making other types of particles, using
24 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 class CParticleManager; // I need this here, so my particle 'knows' the manager and can send messages to him :D
27 class CBaseParticle
29 public:
30 CBaseParticle();
31 CBaseParticle(float x1, float y1, float dx1, float dy1, int color1, int life1);
32 virtual ~CBaseParticle();
34 // the update logic receives the manager, so the particle can add new particles, if desired
35 virtual bool update_logic(CParticleManager &particle_manager); // updates particle's logic, must return TRUE if particle is dead (particle WILL be _deleted_ from memory by manager if dead)
37 virtual void render_particle(BITMAP *bmp, int xd, int yd); // renders particle on bmp, displaced by x,y
39 // all particle properties are public, for easy modification (yeah, I know, poor OO design, don't bug me)
40 float x, y, dx, dy; // particle x,y, and direction (acceleration in x,y)
41 int color; // particle color (in Allegro's makecol format)
42 int life; // remaining life of particle
45 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46 // The particle manager
47 // This handles a bunch of particles
48 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
49 class CParticleManager
51 public:
52 CParticleManager();
53 ~CParticleManager();
55 void nuke_particle_list(); // this will free all memory used by particles, and particles itself.
57 void add_particle(CBaseParticle *node); // adds a particle to manager (the particle WILL be nuked automatically when the manager object gets deleted)
59 void update_logic(); // updates logic of all particles
61 void render(BITMAP *bmp, int x, int y); // renders particles on bmp, displaced by x,y
63 // some public data
64 float add_x, add_y; // displace particles on x, y, this can be used to simulate wind/gravity effects (is add to x,y of all particles)
65 float add_dx, add_dy; // this is add to dx,dy of all particles (can be used to simulate acceleration, etc)
67 private:
68 list <CBaseParticle *> particle_list; // storage for pointers to particles that I must manage
71 #endif