GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


A Paste by Anonymous
1
 
#include "CMissile.h"
#include "explosion.h"
#include "CTexture.h"
#include "CSprite.h"
#include "math.h"
#include "CEnemy.h"
#include "mmgr.h"

float testing=0.0f;

extern CEnemy ai1;


extern GLfloat timeFromStart;

CMissile::CMissile()
{
    speed        = 0.0f;
    damage       = 0;
    splashdamage = 0;
    distance     = 0.0f;
    owner        = 0;
    angle        = 0.0f;
    CVector3 neworg (0.0f,0.0f,0.0f);
    CVector3 engine (0.0f,0.0f,0.0f);
    dead         = false;
}

CMissile::~CMissile()
{

}

void CMissile::Init(CVector3 origin1)
{
    neworg = origin1;
    origin = origin1;
}

void CMissile::Launch(CVector3 org, int weapon)
{
    origin.z = org.z;    
}

void CMissile::Explode(CMissile *ent)
{
    testing = Distance2(origin,neworg);
    if(Distance2(origin,neworg) > distance) {        
        CMissile* before = ent->prev;
        CMissile* after = ent->next;
        if (before) before->next = after;
        if (after) after->prev = before;


        ent->next = ent->prev = NULL; 
        dead=true;
    }
    
}


    
void CMissile::Draw(CMissile *ent)
{
    float dist = Distance2(ai1.origin,origin);

    if( dist < 7 && dist != 0 && owner == 1) {
        ai1.dead = true;
    }

    if(origin.z - neworg.z > distance) {
        speed = 0;
    }

    origin.z = origin.z + speed * dtime();


    glPushMatrix();
        glTranslatef(origin.x,origin.y,origin.z);
        glRotatef(angle,0.0f,1.0f,0.0f);
        model.DrawModel();                
    glPopMatrix();
}