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 #include "utils.h" 00011 #include "video.h" 00012 00013 using namespace std; 00014 using namespace hoa_video::private_video; 00015 00016 namespace hoa_video 00017 { 00018 00019 00020 //----------------------------------------------------------------------------- 00021 // AddParticleEffect: adds a new particle effect to the particle manager. Once you 00022 // call this function, you don't have to do any more work. The 00023 // effect will display until it's over, and then it will automatically 00024 // get destroyed by the particle manager. However, an ID is returned 00025 // by this function in case you want to do things like move the 00026 // position of the effect around. (for exmaple, if you want to 00027 // attach a flame effect to a sword or something) 00028 //----------------------------------------------------------------------------- 00029 00030 ParticleEffectID GameVideo::AddParticleEffect(const string &filename, float x, float y, bool reload) 00031 { 00032 ParticleEffectDef *def = NULL; 00033 00034 bool effect_loaded = _particle_effect_defs.find(filename) != _particle_effect_defs.end(); 00035 00036 if(effect_loaded && !reload) 00037 { 00038 def = _particle_effect_defs[filename]; 00039 } 00040 else 00041 { 00042 def = _particle_manager.LoadEffect(filename); 00043 if(effect_loaded) 00044 delete _particle_effect_defs[filename]; 00045 _particle_effect_defs[filename] = def; 00046 } 00047 00048 if(!def) 00049 { 00050 if(VIDEO_DEBUG) 00051 cerr << "VIDEO ERROR: failed to load particle definition file: " << filename << endl; 00052 return VIDEO_INVALID_EFFECT; 00053 } 00054 00055 ParticleEffectID id = _particle_manager.AddEffect(def, x, y); 00056 00057 if(id == VIDEO_INVALID_EFFECT) 00058 { 00059 if(VIDEO_DEBUG) 00060 cerr << "VIDEO ERROR: failed to add effect to particle manager in GameVideo::AddParticleEffect()!" << endl; 00061 } 00062 00063 return id; 00064 } 00065 00066 00067 //----------------------------------------------------------------------------- 00068 // DrawParticleEffects: call this once per frame. You should call this after 00069 // rendering things like tiles, characters, and monsters, 00070 // but before rendering the GUI. 00071 //----------------------------------------------------------------------------- 00072 00073 bool GameVideo::DrawParticleEffects() 00074 { 00075 return _particle_manager.Draw(); 00076 } 00077 00078 00079 //----------------------------------------------------------------------------- 00080 // StopAllParticleEffects: stops all current particle effects. Pass true if 00081 // you want them to all stop immediately, or false (Default) 00082 // to simply stop emitting new particles 00083 //----------------------------------------------------------------------------- 00084 00085 void GameVideo::StopAllParticleEffects(bool kill_immediate) 00086 { 00087 return _particle_manager.StopAll(); 00088 } 00089 00090 00091 //----------------------------------------------------------------------------- 00092 // GetParticleEffect: returns the ParticleEffect object for an id. If the 00093 // particle system which had that id has expired already, 00094 // or an invalid id is passed, then NULL is returned. 00095 //----------------------------------------------------------------------------- 00096 00097 ParticleEffect *GameVideo::GetParticleEffect(ParticleEffectID id) 00098 { 00099 return _particle_manager.GetEffect(id); 00100 } 00101 00102 00103 //----------------------------------------------------------------------------- 00104 // GetNumParticles: returns the total number of particles being displayed on 00105 // screen 00106 //----------------------------------------------------------------------------- 00107 00108 int32 GameVideo::GetNumParticles() 00109 { 00110 return _particle_manager.GetNumParticles(); 00111 } 00112 00113 00114 00115 00116 } // namespace hoa_video
1.5.1