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 "ill_bubble.h" 00024 #include "explosion_smoke.h" 00025 #include "../game/time.h" 00026 #include "../tool/random.h" 00027 00028 // Vibration period of the bubble 00029 const uint vib_period = 250; 00030 00031 IllBubble::IllBubble() : ExplosionSmoke(20) 00032 { 00033 // delete the sprite of the ExplosionSmoke 00034 delete image; 00035 image = ParticleEngine::GetSprite(ILL_BUBBLE_spr); 00036 SetAirResistFactor( GetAirResistFactor() * 3.0 ); 00037 vib_phi = randomObj.GetLong(0, vib_period); 00038 } 00039 00040 void IllBubble::Draw() 00041 { 00042 if (m_left_time_to_live > m_initial_time_to_live - 3) 00043 image->SetAlpha( (float)(m_initial_time_to_live - m_left_time_to_live) / 3.0 ); 00044 else 00045 image->SetAlpha(1.0); 00046 00047 uint time = (Time::GetInstance()->Read() + vib_phi) % vib_period; 00048 float scale_x, scale_y; 00049 image->GetScaleFactors(scale_x, scale_y); 00050 scale_x *= 1.0 + 0.2 * sin(2.0 * M_PI * time / (float)vib_period); 00051 scale_y *= 1.0 + 0.2 * cos(2.0 * M_PI * time / (float)vib_period); 00052 image->Scale(scale_x, scale_y); 00053 00054 if (m_left_time_to_live > 0) 00055 image->Draw(GetPosition()+Point2i(dx,0) - image->GetSize() / 2); 00056 }