Rebuild autotool system
[construo.git] / particle_factory.hxx
blob5e8ba016240988a3914965048b9a90a7319eabf8
1 // $Id: particle_factory.hxx,v 1.8 2003/01/08 23:14:59 grumbel Exp $
2 //
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
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.
15 //
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
23 #include <vector>
24 #include "vector2d.hxx"
25 #include "lispreader.hxx"
27 class ZoomGraphicContext;
28 class Particle;
29 class World;
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 */
35 class ParticleFactory
37 private:
38 /** Pointer to the world holding this ParticleManager */
39 World* world;
41 std::vector<Particle*> particles;
43 /** the id of next particle that will get created */
44 int particle_id_count;
45 public:
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(); }
79 void clear ();
80 void write_lisp(FILE* out);
82 private:
83 ParticleFactory (const ParticleFactory&);
84 ParticleFactory& operator= (const ParticleFactory&);
87 #endif
89 /* EOF */