Solution Explorer

main.cpp

programs.cpp

code.cpp

resume.cpp

aboutMe.cpp

struct Focal_Point_Code {

Welcome to my Focal Point Code page. Here you can see a few snippets of code that I wrote for my game Focal Point.

I mentioned in the Focal Point project page that the hardest thing about making Focal Point was trying to find an equation that would scale well with the magnifying glass gaining more power. What I ended up doing was defining two variables that define a sweet spot range from an object. This sweet spot range is where the magnifying glass has the most power, and the most amount of power the magnifying glass can have is directly based on its size. This means the play must refocus as they grow to reach max power because as the size grows so does the distance from the ground. Finally, every object has a heat Resistance value. This value is subtracted from the power of the magnifying glass. Because the max power of the magnifying glass is directly related to its size, this ensures that magnifying glass size must be greater than the objects heat resistance in order to burn it. This code is shown below in Focal_Point_Code_1.

Focal_Point_Code_1: burning code

//should we burn the object?
if (magToGeoDistance > 0 && geo != null)
{
    float difference = 0;
    if (geo.invincible)
    {
        rumble = false;
        drawFire = false;
        drawSmoke = false;
        mBurningCue.Pause();
        mBuringIsPlaying = false;
        magStrength = 0;
        targetMaxLife = 1;
        targetResistance = 0;
        targetLife = targetMaxLife;
        
        if (magToGeoDistance < minSweetDist)
            difference = magToGeoDistance - sweetSpot;
        else if(magToGeoDistance > maxSweetDist)
            difference = sweetSpot - magToGeoDistance;

         magStrength = magnifier.size - Math.Abs(difference);
    }
    else
    {
        if (magToGeoDistance < minSweetDist)
            difference = magToGeoDistance - sweetSpot;
        else if (magToGeoDistance > maxSweetDist)
            difference = sweetSpot - magToGeoDistance;

        magStrength = magnifier.size - Math.Abs(difference);
        targetResistance = geo.heatResistance;
        targetMaxLife = geo.maxLife;
        targetLife = geo.life;
    }

    //Quickly factor in the heat resistance of the target
    magStrength = magStrength - geo.heatResistance;

    //Burn the target if final strength is above 0
    if (magStrength > 0)
    {
        if (geo.invincible)
            return;
        
        drawFire = true;

        particleSettingsFire.update(5 * (magStrength / magnifier.size), 1, colPos);

        if (magToGeoDistance > minSweetDist && magToGeoDistance < maxSweetDist)
        {
            particleSettingsSmoke.emitterPos = colPos;
            particleSettingsFire.update(particleSettingsFire.scaleSpeed,
                                        particleSettingsFire.particlesPerStep*2,
                                        colPos);
            drawSmoke = true;
        }
        else if(drawSmoke == true)
            drawSmoke = false;

        geo.life -= magStrength * gameSec;
        if (targetLife < 0)
            targetLife = 0;

        adjustBuringVolume();
        if (!mBuringIsPlaying)
        {
            mBuringIsPlaying = true;
            mBurningCue.Resume();
        }
    }
    else

    {
        mBuringIsPlaying = false;
        mBurningCue.Pause();
        drawFire = false;
        drawSmoke = false;
    }
}

}//end Focal_Point_Code