virtual bool EmitParticles(IParticleContext *context, QList<particle_t*> &particles)
    {
        if (!initialized)
        {
            initialized = true;
            time = qlerp(qfrand(), initial_delay_min, initial_delay_max);
        }

        time -= context->GetFrametime();

        if (time > 0)
            return true;

        int delta = amount_max - amount_min;
        delta = MAX(1, delta);

        int count = qlerp(qPow(qfrand(), exponent) + (0.5f/delta), amount_min, amount_max);

        while (count-- > 0)
        {
            particles.push_back(new particle_t());

            if (emit_children)
            {
                context->EmitChildParticle();
            }
        }

        return false;
    }
    virtual void Spawn()
    {
        yspeed = qlerp(qfrand(), FIGHTER_1_Y_SPEED_MIN, FIGHTER_1_Y_SPEED_MAX);
        startTime = GetGameContext()->GetGameTime() + qfrand() * 1.0f;
        salvoCount = 0;
        movingDown = qbrand();

        float yspeed = movingDown ? -FIGHTER_1_X_SPEED : FIGHTER_1_X_SPEED;
        GetShip()->SetVelocity(Vector2D(FIGHTER_1_X_SPEED, yspeed));
    }
Beispiel #3
0
 void on_update(const UpdateEvent & e) override
 {
     cameraController.update(e.timestep_ms);
     animator.update(e.timestep_ms);
     
     auto what = spherical(zeroOne * ANVIL_PI, zeroOne * ANVIL_PI / 2);
     
     float3 newPos = float3(what.x, 1, what.z) * float3(24, 8, 24);
     std::cout << newPos << std::endl;
     camera.set_position(float3(newPos.x, newPos.y, newPos.z));
     
     // Option One
     camera.look_at(camera.pose.position, {-8, 2, 0});
     
     // Option Two
     camera.pose.orientation = qlerp(start.orientation, end.orientation, zeroOne);
 }
void LaserBeam::OnSimulate(float frametime)
{
    BaseClass::OnSimulate(frametime);

    float laserLength = Camera::GetInstance()->GetWorldMaxs().x - Camera::GetInstance()->GetWorldMins().x;
    float gameTime = GetGameContext()->GetGameTime();

    SetSize(Vector2D(laserLength, LASER_MAX_SIZE_Y));

    Entity *owner = GetOwner();

    if (owner == nullptr
            || timer < gameTime)
    {
        Remove();
    }
    else
    {
        Vector2D center = owner->GetOrigin();
        center.x -= laserLength * 0.5f;
        center += offset;

        if (!spawned)
        {
            Teleport(center);
            spawned = true;
        }
        else
        {
            SetOrigin(center);
        }
    }

    if (flashTimer < gameTime)
    {
        flashSize = fixedSize;
        fixedSize = qlerp(qfrand(), LASER_MIN_SIZE_Y, LASER_MAX_SIZE_Y);
        flashTimer = gameTime + LASER_FLASH_DURATION;
    }
}
 virtual void InitializeParticle(IParticleContext *context, particle_t &particle)
 {
     particle.data_initial.lifetime = qlerp(qPow(qfrand(), exponent), lifetime_min, lifetime_max);
 }
 virtual void InitializeParticle(IParticleContext *context, particle_t &particle)
 {
     particle.data_initial.color[0] = qlerp(qPow(qfrand(), exponent), r_min, r_max) * scale;
     particle.data_initial.color[1] = qlerp(qPow(qfrand(), exponent), g_min, g_max) * scale;
     particle.data_initial.color[2] = qlerp(qPow(qfrand(), exponent), b_min, b_max) * scale;
 }