Example #1
0
void Camera::Move2D(int x, int y) {
    //compute the mouse delta from the previous mouse position
    glm::vec3 mouse_delta = glm::vec3(x, y, 0) * 3.0F;
    //if the camera is moving, meaning that the mouse was clicked and dragged, change the pitch and heading
    if (move_camera) {
        ChangeHeading(.08f * mouse_delta.x);
        ChangePitch(.08f * mouse_delta.y);
    }
    //mouse_position = glm::vec3(x, y, 0);
}
Example #2
0
void CHSMissile::DoCycle()
{
    // Do we need to delete ourselves?
    if (m_delete_me)
    {
        // Remove us from space
        CHSUniverse *cSource;
        cSource = GetUniverse();
        if (cSource)
        {
            cSource->RemoveObject(this);
        }

        // Purge the object representing the missile prior to deallocating
        // memory
        if (hsInterface.ValidObject(GetDbref()))
        {
            hsInterface.DestroyObject(GetDbref());
        }

        return;
    }

    // If we have no target or no parent, remove us from space.
    if (!m_target || !m_pData || !m_target->IsActive())
    {
        hs_log("CHSMissile::DoCycle() Missile Data Invalid - Removing Object.");
        m_delete_me = true;
        return;
    }

    // Do we know how much time is left until we die?
    if (m_timeleft < 0)
    {
        CalculateTimeLeft();
    }
    else
    {
        m_timeleft--;
    }

    // Missile depleted?
    if (0 == m_timeleft)
    {

        m_delete_me = true;
        return;
    }

    // Change the missile heading toward the target
    ChangeHeading();

    // Move us closer to the target.
    MoveTowardTarget();

    // The MoveTowardTarget() checks to see if the missile hits
    // so we just have to check our flag.
    if (m_target_hit)
    {

        // If we aren't designated to miss, apply damage
        if (m_specified_miss != true)
        {
            // BOOM!
            HitTarget();
        }

        m_delete_me = true;     // Delete next time around
    }
}