Combat Area - Code Sample

GLint cbk_object_data::update(GLfloat time_slice)
{
    GLfloat XRotate = c_rotation.GetValue(1);
    GLfloat XPosition = c_position.GetValue(1);
    GLfloat YPosition = c_position.GetValue(2);
    GLfloat ZPosition = c_position.GetValue(3);

    //Reduce Turbo Time
    if (TurboCoolDownTime > time_slice) {
        TurboCoolDownTime -= time_slice;
    } else {
        TurboCoolDownTime = 0;
    }
    if (TurboTimeRemaining > time_slice) {
        TurboTimeRemaining -= time_slice;
    } else {
        TurboTimeRemaining = 0;
    }

    //Rotate Object
    XRotate += c_rotation_speed * time_slice;
    c_rotation_speed *= pow(c_Rotation_Decay, time_slice);
    if (fabs(c_rotation_speed) < 0.1f) {c_rotation_speed = 0.0f;}
    if (XRotate > 360.0f) {XRotate -= 360.0f;}
    if (XRotate <= 0.0f) {XRotate += 360.0f;}
    c_rotation.SetValue(1, XRotate);

    //Move Object
    XPosition += ((sin(Degrees2Radians((float) c_rotation.GetValue(1)))) * (c_movement_speed * time_slice));
    ZPosition += ((cos(Degrees2Radians((float) c_rotation.GetValue(1)))) * (c_movement_speed * time_slice));
    c_movement_speed *= pow(c_Movement_Decay, time_slice);
    if (fabs(c_movement_speed) < 0.1f) {c_movement_speed = 0.0f;}
    if (XPosition >= WorldSize)      {XPosition -= WorldSize;}
    else if (XPosition < 0)          {XPosition += WorldSize;}
    if (ZPosition >= WorldSize)      {ZPosition -= WorldSize;}
    else if (ZPosition < 0)          {ZPosition += WorldSize;}

    if (c_LifeTime != -1) {
        if (c_LifeTime > time_slice) {
            c_LifeTime -= time_slice;
        } else {
            return true;
        }
    }

    c_position.SetValue(XPosition, YPosition, ZPosition);

    return false;
}