00001 // $Id: particle_factory.hxx,v 1.8 2003/01/08 23:14:59 grumbel Exp $ 00002 // 00003 // Construo - A wire-frame construction game 00004 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de> 00005 // 00006 // This program is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU General Public License 00008 // as published by the Free Software Foundation; either version 2 00009 // of the License, or (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 #ifndef HEADER_CONSTRUO_PARTICLE_FACTORY_HXX 00021 #define HEADER_CONSTRUO_PARTICLE_FACTORY_HXX 00022 00023 #include <vector> 00024 #include "vector2d.hxx" 00025 #include "lispreader.hxx" 00026 00027 class ZoomGraphicContext; 00028 class Particle; 00029 class World; 00030 00032 typedef int ParticleId; 00033 00035 class ParticleFactory 00036 { 00037 private: 00039 World* world; 00040 00041 std::vector<Particle*> particles; 00042 00044 int particle_id_count; 00045 public: 00047 ParticleFactory (World*); 00048 00050 ParticleFactory (World*, lisp_object_t* cursor); 00051 00053 ParticleFactory (World*, const ParticleFactory&); 00054 00055 Particle* add_particle (const Vector2d& arg_pos, const Vector2d& arg_velocity, 00056 float m, bool f = false); 00057 00059 Particle* add_particle (const Particle& particle); 00060 00062 void remove_particle (Particle*); 00063 00065 void remove_particle (int id); 00066 00067 int size () { return particles.size(); } 00068 Particle* lookup_particle (int id); 00069 00070 void update (float delta); 00071 void draw (ZoomGraphicContext* gc); 00072 00073 typedef std::vector<Particle*>::const_iterator CParticleIter; 00074 typedef std::vector<Particle*>::iterator ParticleIter; 00075 00076 ParticleIter begin () { return particles.begin(); } 00077 ParticleIter end () { return particles.end(); } 00078 00079 void clear (); 00080 void write_lisp(FILE* out); 00081 00082 private: 00083 ParticleFactory (const ParticleFactory&); 00084 ParticleFactory& operator= (const ParticleFactory&); 00085 }; 00086 00087 #endif 00088 00089 /* EOF */