mirror of
https://github.com/glest/glest-source.git
synced 2025-02-26 12:43:06 +01:00
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
|
// ==============================================================
|
|||
|
// This file is part of Glest (www.glest.org)
|
|||
|
//
|
|||
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
|||
|
//
|
|||
|
// You can redistribute this code and/or modify it under
|
|||
|
// the terms of the GNU General Public License as published
|
|||
|
// by the Free Software Foundation; either version 2 of the
|
|||
|
// License, or (at your option) any later version
|
|||
|
// ==============================================================
|
|||
|
|
|||
|
#include "water_effects.h"
|
|||
|
|
|||
|
#include "config.h"
|
|||
|
#include "map.h"
|
|||
|
#include "leak_dumper.h"
|
|||
|
|
|||
|
namespace Glest{ namespace Game{
|
|||
|
|
|||
|
// =====================================================
|
|||
|
// class WaterSplash
|
|||
|
// =====================================================
|
|||
|
|
|||
|
WaterSplash::WaterSplash(const Vec2f &pos, int size){
|
|||
|
this->pos= pos;
|
|||
|
this->size=1+(size-1)/2;
|
|||
|
anim= 0.f;
|
|||
|
enabled= true;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void WaterSplash::update(float amount){
|
|||
|
if(enabled){
|
|||
|
anim+= amount/size;
|
|||
|
if(anim>1.f){
|
|||
|
enabled= false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// ===============================
|
|||
|
// class WaterEffects
|
|||
|
// ===============================
|
|||
|
|
|||
|
WaterEffects::WaterEffects(){
|
|||
|
anim= 0;
|
|||
|
}
|
|||
|
|
|||
|
void WaterEffects::update(){
|
|||
|
anim+= 0.5f/GameConstants::updateFps;
|
|||
|
if(anim>1.f){
|
|||
|
anim= 0;
|
|||
|
}
|
|||
|
for(int i=0; i<waterSplashes.size(); ++i){
|
|||
|
waterSplashes[i].update(1.f/GameConstants::updateFps);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void WaterEffects::addWaterSplash(const Vec2f &pos, int size){
|
|||
|
for(int i=0; i<waterSplashes.size(); ++i){
|
|||
|
if(!waterSplashes[i].getEnabled()){
|
|||
|
waterSplashes[i]= WaterSplash(pos,size);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
waterSplashes.push_back(WaterSplash(pos,size));
|
|||
|
}
|
|||
|
|
|||
|
}}//end namespace
|