Skip to content

Commit

Permalink
fix lock to player x
Browse files Browse the repository at this point in the history
  • Loading branch information
theyareonit committed Jul 6, 2024
1 parent d0611a7 commit 45bcf3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.1.17

* fix lock to player x again oops

# v1.1.16

* Fix various velocity bugs caused by moving platforms
Expand Down
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ CCPoint p1Pos = { NULL, NULL };
CCPoint p2Pos = { NULL, NULL };
float p1RotationDelta;
float p2RotationDelta;
bool midStep = false;

class $modify(PlayerObject) {
void update(float timeFactor) {
Expand Down Expand Up @@ -456,6 +457,7 @@ class $modify(PlayerObject) {
p2Pos = p2->getPosition();

step step;
midStep = true;

do {
step = updateDeltaFactorAndInput();
Expand Down Expand Up @@ -505,22 +507,24 @@ class $modify(PlayerObject) {
firstLoop = false;

} while (!step.endStep);

midStep = false;
}

void updateRotation(float t) {
PlayLayer* pl = PlayLayer::get();
if (!skipUpdate && pl && this == pl->m_player1) {
PlayerObject::updateRotation(p1RotationDelta);

if (p1Pos.x && !skipUpdate) { // to happen only when GJBGL::update() calls updateRotation after an input
if (p1Pos.x && !midStep) { // to happen only when GJBGL::update() calls updateRotation after an input
this->m_lastPosition = p1Pos;
p1Pos.setPoint(NULL, NULL);
}
}
else if (!skipUpdate && pl && this == pl->m_player2) {
PlayerObject::updateRotation(p2RotationDelta);

if (p2Pos.x && !skipUpdate) {
if (p2Pos.x && !midStep) {
pl->m_player2->m_lastPosition = p2Pos;
p2Pos.setPoint(NULL, NULL);
}
Expand Down

0 comments on commit 45bcf3d

Please sign in to comment.