00001 00002 // Copyright (C) 2004-2007 by The Allacrost Project 00003 // All Rights Reserved 00004 // 00005 // This code is licensed under the GNU GPL version 2. It is free software 00006 // and you may modify it and/or redistribute it under the terms of this license. 00007 // See http://www.gnu.org/copyleft/gpl.html for details. 00009 00010 /*!**************************************************************************** 00011 * \file particle_manager.h 00012 * \author Raj Sharma, roos@allacrost.org 00013 * \brief Header file for particle manager 00014 * 00015 * The particle manager is very simple. Every time you want to draw an effect, 00016 * you call AddEffect() with a pointer to the effect definition structure. 00017 * Then every frame, call Update() and Draw() to draw all the effects. 00018 *****************************************************************************/ 00019 00020 #ifndef __PARTICLE_MANAGER_HEADER__ 00021 #define __PARTICLE_MANAGER_HEADER__ 00022 00023 #include "defs.h" 00024 #include "utils.h" 00025 00027 typedef int32 ParticleEffectID; 00028 00030 const ParticleEffectID VIDEO_INVALID_EFFECT = -1; 00031 00032 namespace hoa_video 00033 { 00034 00035 namespace private_video 00036 { 00037 00038 #include "utils.h" 00039 00040 00041 /*!*************************************************************************** 00042 * \brief ParticleManager, used internally by video engine to store/update/draw 00043 * all particle effects. 00044 *****************************************************************************/ 00045 00046 class ParticleManager 00047 { 00048 public: 00049 00053 ParticleManager() { _current_id = 0; } 00054 00060 ParticleEffectDef *LoadEffect(const std::string &filename); 00061 00062 00072 ParticleEffectID AddEffect(const ParticleEffectDef *def, float x, float y); 00073 00074 00079 bool Draw(); 00080 00081 00087 bool Update(int32 frame_time); 00088 00089 00098 void StopAll(bool kill_immediate = false); 00099 00100 00109 ParticleEffect *GetEffect(ParticleEffectID id); 00110 00111 00116 int32 GetNumParticles(); 00117 00118 00122 void Destroy(); 00123 00124 private: 00125 00132 ParticleEffect *_CreateEffect(const ParticleEffectDef *def); 00133 00136 std::map<ParticleEffectID, ParticleEffect *> _effects; 00137 00139 int32 _current_id; 00140 00144 int32 _num_particles; 00145 }; 00146 00147 } // namespace private_video 00148 } // namespace hoa_video 00149 00150 #endif // !__PARTICLE_MANAGER_HEADER
1.5.1