1 // $Id: particle_factory.hxx,v 1.8 2003/01/08 23:14:59 grumbel Exp $
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_CONSTRUO_PARTICLE_FACTORY_HXX
21 #define HEADER_CONSTRUO_PARTICLE_FACTORY_HXX
24 #include "vector2d.hxx"
25 #include "lispreader.hxx"
27 class ZoomGraphicContext
;
31 /** id of a particle, uniq only for a single ParticleFactory */
32 typedef int ParticleId
;
34 /** Its really more a particle manager, but lets see */
38 /** Pointer to the world holding this ParticleManager */
41 std::vector
<Particle
*> particles
;
43 /** the id of next particle that will get created */
44 int particle_id_count
;
46 /** Create an empty particle manager */
47 ParticleFactory (World
*);
49 /** Create a particle manager from the data in a .construo file */
50 ParticleFactory (World
*, lisp_object_t
* cursor
);
52 /** Copy a particle manager, the id's will be keep */
53 ParticleFactory (World
*, const ParticleFactory
&);
55 Particle
* add_particle (const Vector2d
& arg_pos
, const Vector2d
& arg_velocity
,
56 float m
, bool f
= false);
58 /** Duplicate a particle */
59 Particle
* add_particle (const Particle
& particle
);
61 /** Remove a particle by pointer */
62 void remove_particle (Particle
*);
64 /** Remove a particle by id */
65 void remove_particle (int id
);
67 int size () { return particles
.size(); }
68 Particle
* lookup_particle (int id
);
70 void update (float delta
);
71 void draw (ZoomGraphicContext
* gc
);
73 typedef std::vector
<Particle
*>::const_iterator CParticleIter
;
74 typedef std::vector
<Particle
*>::iterator ParticleIter
;
76 ParticleIter
begin () { return particles
.begin(); }
77 ParticleIter
end () { return particles
.end(); }
80 void write_lisp(FILE* out
);
83 ParticleFactory (const ParticleFactory
&);
84 ParticleFactory
& operator= (const ParticleFactory
&);