Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

BattleSprite.cpp

Go to the documentation of this file.
00001 /*
00002 CS Senior Project 2003
00003 Team : Leftfield
00004 Project : ModernWarfare
00005 Members :
00006 - Russ Christensen              <rchriste@cs.utah.edu>
00007 - Todd Smith                    <tcsmith@cs.utah.edu>
00008 - Usit Duongsaa                 <duongsaa@cs.utah.edu>
00009 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00012 
00013 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
00014 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
00015 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00016 */
00017 
00022 #include "BattleSprite.h"
00023 #include "Globals.h"
00024 
00025 //------------------------------------------------------------------------------------
00026 // bridgeFunc(x) = 0  if x =0 or x= max
00027 //               = 1  if x = max/2
00028 // and a smooth curve interpolation in between
00029 FLOAT bridgeFunc( FLOAT x, FLOAT max )
00030 {
00031         FLOAT delta = 1.0f - 2.0f*absf(max-x)/max;      
00032         return sqrtf(delta);
00033 }
00034 //------------------------------------------------------------------------------------
00035 void updateParticleList( list<BattleSprite> &sprites )
00036 {
00037         list<BattleSprite>::iterator iter = sprites.begin();
00038         while( iter!=sprites.end() )                                                    // delete those whose time ran out
00039         {
00040                 int timeLeft = iter->timeRemaining--;
00041                 list<BattleSprite>::iterator toDel(iter);
00042                 iter++;
00043                 if( timeLeft <= 0 )
00044                         sprites.erase(toDel);           
00045         }
00046 }
00047 //------------------------------------------------------------------------------------
00048 void renderParticleList( list<BattleSprite> &sprites )
00049 {
00050         list<BattleSprite>::iterator iter = sprites.begin();
00051         ATexture textures[6] = { artWork->smokeTextureSmall, artWork->smokeTextureLarge,
00052                                                          artWork->exploTextureSmall, artWork->exploTextureLarge,
00053                                                          artWork->artilTextureShell, artWork->exploTextureSmall };
00054         FLOAT maxTime[6] = { 65, 75, 20, 45, 15, 15 };
00055         FLOAT baseSize[6] = { 6.0f, 8.0f, 5.0f, 8.0f, 6.0f, 2.6f };
00056         int blendMode[6] = { BlendModes::MIX, BlendModes::MIX, BlendModes::ADD,
00057                                                  BlendModes::ADD, BlendModes::ADD, BlendModes::ADD };
00058         while( iter!=sprites.end() )
00059         {
00060                 int type = iter->type;
00061                 FLOAT max = maxTime[type];
00062                 FLOAT v = bridgeFunc( (FLOAT)iter->timeRemaining, max );
00063                 Vec4D mult(1,1,1, v );
00064                 FLOAT size = v + (max-iter->timeRemaining)/max;
00065                 sprite_add( textures[type], blendMode[type], iter->pos, mult, size*baseSize[type] );
00066                 iter++;
00067         }
00068 }
00069 //------------------------------------------------------------------------------------

Generated on Wed Apr 23 05:50:14 2003 for Modern Warfare by doxygen1.3-rc2