Skip to content

Commit

Permalink
the nuclear option...
Browse files Browse the repository at this point in the history
  • Loading branch information
theyareonit committed Jun 17, 2024
1 parent 9dcf401 commit 7881484
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v1.1.5

* Improve input precision again
* Future proof for physics bypass
* Fix buffer clicks for the final time.......

# v1.1.4

Expand Down
31 changes: 22 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,29 +402,42 @@ class $modify(PlayerObject) {

if (this == pl->m_player2) return;

step step = updateDeltaFactorAndInput();

bool p1StartedOnGround = this->m_isOnGround; // this gets set to false if you run PlayerObject::update without doing a collision check, so we need to save its state
bool p2StartedOnGround = pl->m_player2->m_isOnGround;
bool p1IsFlying = (this->m_isDart || this->m_isBird || this->m_isShip || this->m_isSwing);
bool p2IsFlying = (pl->m_player2->m_isDart || pl->m_player2->m_isBird || pl->m_player2->m_isShip || pl->m_player2->m_isSwing);

bool isDual = pl->m_gameState.m_isDualMode;
bool p1OnGround;
bool p2OnGround;
bool firstLoop = true;

step step = updateDeltaFactorAndInput();

while (true) {
const float newTimeFactor = timeFactor * step.deltaFactor;

p1OnGround = this->m_isOnGround; // this gets set to false if you run PlayerObject::update without doing a collision check, so we need to save its state
if (isDual) p2OnGround = pl->m_player2->m_isOnGround;
if (p1StartedOnGround || p1IsFlying) PlayerObject::update(newTimeFactor);
else if (step.endStep) PlayerObject::update(timeFactor);

PlayerObject::update(newTimeFactor);
if (isDual) {
skipUpdate = true; // re-enable PlayerObject::update() for player 2
pl->m_player2->update(newTimeFactor);
if (p2StartedOnGround || p2IsFlying) pl->m_player2->update(newTimeFactor);
else if (step.endStep) pl->m_player2->update(timeFactor);
skipUpdate = false;
}

if (step.endStep) break;

this->m_isOnGround = p1OnGround;
if (isDual) pl->m_player2->m_isOnGround = p2OnGround;
if (firstLoop) {
this->m_isOnGround = p1StartedOnGround;
if (isDual) pl->m_player2->m_isOnGround = p2StartedOnGround;
}
else {
this->m_isOnGround = false;
if (isDual) pl->m_player2->m_isOnGround = false;
}

firstLoop = false;
step = updateDeltaFactorAndInput();
}
}
Expand Down

0 comments on commit 7881484

Please sign in to comment.