src/particles/particle.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Particle Engine
00020  *****************************************************************************/
00021 
00022 #ifndef PARTICLE_H
00023 #define PARTICLE_H
00024 #include "../object/physical_obj.h"
00025 #include "../graphic/sprite.h"
00026 #include "../graphic/surface.h"
00027 #include "../include/base.h"
00028 #include "../weapon/weapon_cfg.h"
00029 
00030 typedef enum {
00031   particle_DARK_SMOKE,
00032   particle_SMOKE,
00033   particle_ILL_BUBBLE,
00034   particle_FIRE,
00035   particle_STAR,
00036   particle_BULLET,
00037   particle_GROUND,
00038   particle_AIR_HAMMER,
00039   particle_MAGIC_STAR,
00040   particle_BODY_MEMBER,
00041   particle_TELEPORT_MEMBER,
00042   particle_POLECAT_FART
00043 } particle_t;
00044 
00045 enum particle_spr
00046 {
00047   SMOKE_spr,
00048   EXPLOSION_SMOKE_spr,
00049   ILL_BUBBLE_spr,
00050   FIRE_spr, STAR_spr,
00051   MAGIC_STAR_R_spr,
00052   MAGIC_STAR_Y_spr,
00053   MAGIC_STAR_B_spr,
00054   DARK_SMOKE_spr,
00055   BULLET_spr,
00056   POLECAT_FART_spr
00057 };
00058 const int particle_spr_nbr = POLECAT_FART_spr + 1;
00059 
00060 class Particle : public PhysicalObj
00061 {
00062  protected:
00063   bool on_top; // if true displayed on top of characters and weapons
00064   uint m_initial_time_to_live;
00065   uint m_left_time_to_live;
00066   bool m_check_move_on_end_turn;
00067   uint m_time_between_scale;
00068   uint m_last_refresh;
00069 
00070   Sprite *image;
00071 
00072  public:
00073   Particle(const std::string &name);
00074   ~Particle();
00075   virtual void Draw();
00076   virtual void Refresh();
00077   void SetOnTop(bool b) { on_top = b; }
00078   bool IsOnTop() { return on_top; }
00079   bool StillUseful();
00080   const bool CheckOnEndTurn() { return m_check_move_on_end_turn; }
00081 };
00082 
00083 class ParticleEngine
00084 {
00085  private:
00086   uint m_last_refresh;
00087   uint m_time_between_add;
00088 
00089   static Sprite* particle_sprite[particle_spr_nbr];
00090   static std::list<Particle *> lst_particles;
00091 
00092   static void AddLittleESmoke(const Point2i &pos, const uint &radius);
00093   static void AddBigESmoke(const Point2i &pos, const uint &radius);
00094 
00095  public:
00096   ParticleEngine(uint time=100);
00097   void AddPeriodic(const Point2i &position,
00098                    particle_t type,
00099                    bool upper,
00100                    double angle=-1, double norme=-1);
00101 
00102   static void Init();
00103   static void FreeMem();
00104   static Sprite* GetSprite(particle_spr type);
00105 
00106   static void AddNow(const Point2i &position,
00107                      uint nb_particles, particle_t type,
00108                      bool upper,
00109                      double angle=-1, double norme=-1);
00110   static void AddNow(Particle* particle);
00111 
00112   enum ESmokeStyle { NoESmoke, LittleESmoke, BigESmoke }; // Style of smoke explosion (quantitie of smoke)
00113   static void AddExplosionSmoke(const Point2i &pos, const uint &radius, ESmokeStyle &style);
00114 
00115   static void Refresh();
00116   static void Draw(bool upper);
00117   static void Stop();
00118   static PhysicalObj * IsSomethingMoving();
00119 };
00120 
00121 #endif

Generated on Mon Jan 1 13:10:59 2007 for Wormux by  doxygen 1.4.7