Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua function "u_forceIncrement" doesn't actually increment level difficulty #417

Open
minamoto-hikari opened this issue Jun 23, 2024 · 0 comments

Comments

@minamoto-hikari
Copy link

After wanting to make a custom level that increases in difficulty after certain patterns and not on a timer, I tried using the function u_forceIncrement to do it, but the function only calls incrementDifficulty.

incrementDifficulty:

void HexagonGame::incrementDifficulty()
{
    playSoundOverride("levelUp.ogg");

    const float signMult = (levelStatus.rotationSpeed > 0.f) ? 1.f : -1.f;

    levelStatus.rotationSpeed += levelStatus.rotationSpeedInc * signMult;

    const auto& rotationSpeedMax(levelStatus.rotationSpeedMax);
    if(std::abs(levelStatus.rotationSpeed) > rotationSpeedMax)
    {
        levelStatus.rotationSpeed = rotationSpeedMax * signMult;
    }

    levelStatus.rotationSpeed *= -1.f;
    status.fastSpin = levelStatus.fastSpin;
}

This sounds correct on paper by the function names, but after looking into the functions "incrementDifficulty" only plays the level up sound and updates the rotation speed.
It does not update the level speed, sides and does not increase the level increments value nor does it end up firing the onIncrement event.

My expected behavior would have been closer to the updateIncrement function:

updateIncrement:

void HexagonGame::updateIncrement()
{
    if(!levelStatus.incEnabled)
    {
        return;
    }

    if(status.getIncrementTimeSeconds() < levelStatus.incTime)
    {
        return;
    }

    ++levelStatus.currentIncrements;
    incrementDifficulty();
    status.resetIncrementTime();
    mustChangeSides = true;
}

So my suggestion would be to add a special forceIncrement function, or change the way incrementDifficuly is implemented.

Example for forceIncrement:

void HexagonGame::forceIncrement(bool mResetTimer)
{
    ++levelStatus.currentIncrements;
    incrementDifficulty();
    if (mResetTimer) {
        status.resetIncrementTime();
    }
    mustChangeSides = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant