theyareonit / Click-Between-Frames

Geometry Dash mod to allow inputs in between visual frames
81 stars 20 forks source link

clicks after death #71

Open Marcs2712 opened 1 month ago

Marcs2712 commented 1 month ago

i have a bug that when i die and in the respawn time i click, in the next attempts it automatically clicks at the very start

https://github.com/user-attachments/assets/7f80a4de-4883-4a99-ae3a-9c73a67ebd4e

LukaTV939 commented 1 month ago

Getting the same thing

Danon5 commented 3 weeks ago

I have no GD modding experience, but I tinkered with it for a while and tried various solutions. It seems like, when the delta time is <= 0 (so, when the game is stopped due to being dead), it needs to consider it a "firstFrame" and "skipUpdate" as well? Before it used to only set "enableInput" to true. This change removes the issue demonstrated in the OP's video. I am testing it in a local copy of the mod that I am compiling.

The current code tries to check if "isDead" is true inside of updateInputQueueAndTime, but I debugged the isDead value and it seems to only be true before the level has started. It never gets set back to false once you begin playing the level even if you die, so I think something like the below fix is needed.

// main.cpp

...
// class $modify(GJBaseGameLayer) {

float getModifiedDelta(float delta) {
    float modifiedDelta = GJBaseGameLayer::getModifiedDelta(delta);

    PlayLayer* pl = PlayLayer::get();
    if (pl) {
        const float timewarp = pl->m_gameState.m_timeWarp;
        if (actualDelta) modifiedDelta = CCDirector::sharedDirector()->getActualDeltaTime() * timewarp;

        const int stepCount = std::round(std::max(1.0, ((modifiedDelta * 60.0) / std::min(1.0f, timewarp)) * 4));

        if (modifiedDelta > 0.0) updateInputQueueAndTime(stepCount);
        else {
            enableInput = true;
            firstFrame = true; // new
            skipUpdate = true; // new
        }
    }

    return modifiedDelta;
}

Maybe someone who is more experienced could see if this is potentially a correct fix? I want to get the ball rolling on this because it's a really annoying issue that makes practicing unplayable 50% of the time on harder levels.

LukaTV939 commented 3 weeks ago

I have no GD modding experience, but I tinkered with it for a while and tried various solutions. It seems like, when the delta time is <= 0 (so, when the game is stopped due to being dead), it needs to consider it a "firstFrame" and "skipUpdate" as well? Before it used to only set "enableInput" to true. This change removes the issue demonstrated in the OP's video. I am testing it in a local copy of the mod that I am compiling.

The current code tries to check if "isDead" is true inside of updateInputQueueAndTime, but I debugged the isDead value and it seems to only be true before the level has started. It never gets set back to false once you begin playing the level even if you die, so I think something like the below fix is needed.

// main.cpp

...
// class $modify(GJBaseGameLayer) {

float getModifiedDelta(float delta) {
  float modifiedDelta = GJBaseGameLayer::getModifiedDelta(delta);

  PlayLayer* pl = PlayLayer::get();
  if (pl) {
      const float timewarp = pl->m_gameState.m_timeWarp;
      if (actualDelta) modifiedDelta = CCDirector::sharedDirector()->getActualDeltaTime() * timewarp;

      const int stepCount = std::round(std::max(1.0, ((modifiedDelta * 60.0) / std::min(1.0f, timewarp)) * 4));

      if (modifiedDelta > 0.0) updateInputQueueAndTime(stepCount);
      else {
          enableInput = true;
          firstFrame = true; // new
          skipUpdate = true; // new
      }
  }

  return modifiedDelta;
}

Maybe someone who is more experienced could see if this is potentially a correct fix? I want to get the ball rolling on this because it's a really annoying issue that makes practicing unplayable 50% of the time on harder levels.

make a Pull Request of this fix please, and thank you

LukaTV939 commented 3 weeks ago

just tested this fix locally and it works, tho you can't buffer in the beginning anymore

Danon5 commented 3 weeks ago

just tested this fix locally and it works, tho you can't buffer in the beginning anymore

I tested with and without the mod, and it feels pretty identical to me. In both cases I can press a few milliseconds early before I respawn and it still jumps. Do you mean something else (like the actual first frame of the level, only jump orbs, etc.) or am I just not good enough to notice the difference? Either way, will make a pull request and maybe that is something that can get fixed later if needed.

LukaTV939 commented 3 weeks ago

just tested this fix locally and it works, tho you can't buffer in the beginning anymore

I tested with and without the mod, and it feels pretty identical to me. In both cases I can press a few milliseconds early before I respawn and it still jumps. Do you mean something else (like the actual first frame of the level, only jump orbs, etc.) or am I just not good enough to notice the difference? Either way, will make a pull request and maybe that is something that can get fixed later if needed.

I'm sure you don't notice it, plus the practice mode is very bugged as some checkpoints are broken by placing when holding, because for some reason the game is holding when respawning even tho I'm not holding

FRBFStudios commented 1 week ago

experiencing this too, please fix :(