00001 00002 /****************************************************************************** 00003 * Wormux is a convivial mass murder game. 00004 * Copyright (C) 2001-2004 Lawrence Azzoug. 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (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 * Particle Engine 00021 *****************************************************************************/ 00022 00023 #include "magic_star.h" 00024 #include "particle.h" 00025 #include "../tool/random.h" 00026 #include "../game/time.h" 00027 00028 MagicStarParticle::MagicStarParticle() : 00029 Particle("magic_star_particle") 00030 { 00031 m_initial_time_to_live = 30; 00032 m_left_time_to_live = m_initial_time_to_live; 00033 m_time_between_scale = 25; 00034 00035 uint color=randomObj.GetLong(0,2); 00036 switch(color) 00037 { 00038 case 0 : image = ParticleEngine::GetSprite(MAGIC_STAR_R_spr); break; 00039 case 1 : image = ParticleEngine::GetSprite(MAGIC_STAR_Y_spr); break; 00040 case 2 : image = ParticleEngine::GetSprite(MAGIC_STAR_B_spr); break; 00041 default: assert(false); 00042 } 00043 image->Scale(0.0, 0.0); 00044 SetSize( Point2i(1, 1) ); 00045 } 00046 00047 void MagicStarParticle::Refresh() 00048 { 00049 uint time = Time::GetInstance()->Read() - m_last_refresh; 00050 if (time >= m_time_between_scale) { 00051 if (m_left_time_to_live <= 0) return ; 00052 float lived_time = m_initial_time_to_live - m_left_time_to_live; 00053 float coeff = sin(M_PI_2*((float)lived_time/((float)m_initial_time_to_live))); 00054 image->SetRotation_rad(coeff * 2 * M_PI); 00055 } 00056 Particle::Refresh(); 00057 }