#include "cSplashParticle.h"


cSplashParticle::cSplashParticle(cParticleSystem* ps) : cParticle(ps) { }


void cSplashParticle::update(float dt, vector<cTriangle*>& tlist)
{
    age_ += dt;
    if(age_ > .5) {dead_ = true; return; }
    
    cVector g(0, -25, 0);
    position_ += velocity_ * dt;
    velocity_ += g * dt;
}
    
void cSplashParticle::draw()
{	
    float scale = .5 - .5 * (age_/.5);
    
    glColor4f(.6,.6,1, .2 - .2 * (age_/.5) );
    
    glBegin(GL_TRIANGLE_STRIP);						// Build Quad From A Triangle Strip
        glTexCoord2d(1,1); glVertex3f(position_.x_+scale, position_.y_+scale, position_.z_); // Top Right
        glTexCoord2d(0,1); glVertex3f(position_.x_-scale, position_.y_+scale, position_.z_); // Top Left
        glTexCoord2d(1,0); glVertex3f(position_.x_+scale, position_.y_-scale, position_.z_); // Bottom Right
        glTexCoord2d(0,0); glVertex3f(position_.x_-scale, position_.y_-scale, position_.z_); // Bottom Left
    glEnd();
    
    glBegin(GL_TRIANGLE_STRIP);						// Build Quad From A Triangle Strip
        glTexCoord2d(1,1); glVertex3f(position_.x_, position_.y_+scale, position_.z_+scale); // Top Right
        glTexCoord2d(0,1); glVertex3f(position_.x_, position_.y_+scale, position_.z_-scale); // Top Left
        glTexCoord2d(1,0); glVertex3f(position_.x_, position_.y_-scale, position_.z_+scale); // Bottom Right
        glTexCoord2d(0,0); glVertex3f(position_.x_, position_.y_-scale, position_.z_-scale); // Bottom Left
    glEnd();
}
