Parallax Background for Forgotten Woods

PHOTO EMBED

Thu Apr 04 2024 20:18:47 GMT+0000 (Coordinated Universal Time)

Saved by @mry2khuu #c++ #c #forgottenwoods #camera #parallax

void ComponentGraphics::UpdateBackground(GLFWwindow* window, Shader shader, ComponentCamera* camera, glm::vec3 difference)
{
    if (camera->getlockParallax() == false)
    {
        if (difference[0] > 0.0001f) //right
        {
            posX -= backgroundSpeed;
        }
        if (difference[0] < -0.0001f) //left
        {
           posX += backgroundSpeed;
        }
    }
    //96.0f / 50.0f, 84.0f / 50.0f
    float CurrentCameraX = camera->getCameraPosition().x;
    UpdateGraphics(0.0001, window, shader, camera, ConvertTo4x4Affine(AffineScaleMatrix(96.0f / 50.0f, 84.0f / 50.0f) * AffineTranslationMatrix(posX, posY)), "NoCamX");
}

void ComponentGraphics::setBackgroundSpeedFromFile(Stream stream)
{
    backgroundSpeed = StreamReadFloat(stream);
}

void ComponentGraphics::setBackgroundSpeed(float speed)
{
   backgroundSpeed = speed;
}

void ComponentGraphics::setPosFromFile(Stream stream)
{
    posX = StreamReadFloat(stream);
    posY = StreamReadFloat(stream);
}
content_copyCOPY