Shockwave.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // Das Tank - Copyright (C) 2006, 2007 Windsor Schmidt <windsor@windsorworld.net>
00004 //
00005 // This program is free software; you can redistribute it and/or modify it
00006 // under the terms of the GNU General Public License as published by the Free
00007 // Software Foundation; either version 2 of the License, or (at your option)
00008 // any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful, but WITHOUT
00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 // more details.
00014 //
00015 // You should have received a copy of the GNU General Public License along with
00016 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017 // Place, Suite 330, Boston, MA 02111-1307 USA
00018 //
00020 
00021 
00022 #ifndef STDAFX
00023 #include "stdafx.h"
00024 #endif
00025 
00026 
00028 Shockwave::Shockwave(void)
00029 {
00030        vPosition.x = 0;
00031        fEnergy = .1;
00032        fAge = 0;
00033        
00034        fColorR = 1; // set default color to white
00035        fColorG = 1;
00036        fColorB = 1;
00037 }
00038 
00039 
00042 Shockwave::Shockwave(Vector vPos, float energy)
00043 {
00044        vPosition = vPos;
00045        fEnergy = energy;
00046        fAge = 0;
00047        
00048        fColorR = 1; // set default color to white
00049        fColorG = 1;
00050        fColorB = 1;
00051 }
00052 
00053 
00055 Shockwave::~Shockwave(void)
00056 {
00057 }
00058 
00059 
00061 void Shockwave::Draw(void)
00062 {
00063        int i;
00064        
00065        glBlendFunc (GL_SRC_ALPHA, GL_ONE);
00066        glEnable (GL_BLEND);
00067        glDisable(GL_TEXTURE_2D);
00068        glPushMatrix();
00069        glTranslatef(vPosition.x, vPosition.y, 0.1);
00070        glColor4f(0.2, 0.6, 1, fEnergy);
00071        DrawDisc(fAge * 0.0025);
00072        glColor4f(fColorR, fColorG, fColorB, fEnergy);
00073        DrawCircle(fAge * 0.0035);
00074        glRotatef(-fAge * 0.1, 0, 0, 1);
00075        glLineWidth(5);
00076        glColor4f(1.0, 1.0, 1.0, fEnergy * 0.4);
00077        DrawStar(fAge * 0.005 - 1);
00078        glLineWidth(1);
00079 
00080        glPopMatrix();
00081 }
00082 
00083 
00087 bool Shockwave::Step(float timeStep)
00088 {
00089        fAge += timeStep;
00090 
00091        fEnergy -= .02;
00092 
00093        if(fEnergy <= 0)
00094        {
00095               return true;
00096        }
00097        else
00098        {
00099               return false;
00100        }
00101 }
00102 
00103 
00106 void Shockwave::SetColor(float r, float g, float b)
00107 {
00108        fColorR = r;
00109        fColorG = g;
00110        fColorB = b;
00111 }

 

Copyright Windsor Schmidt 2006 - All rights reserved.