Skip to content

Commit

Permalink
Merge pull request #186 from JacobDomagala/185-fix-flickering-during-…
Browse files Browse the repository at this point in the history
…enemy-animation

[#185]:  Fix flickering during enemy animation
  • Loading branch information
JacobDomagala authored Jan 17, 2024
2 parents 51ff413 + 7f1b54c commit 3e4cb9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions editor/gizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Gizmo::Initialize()
centerInitialSize_ = {{16, 16}, {96, 96}};
upInitialSize_ = {96, 32};
sideInitialSize_ = {96, 32};

Hide();
}

void
Expand Down
8 changes: 5 additions & 3 deletions engine/game/enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ Enemy::EnemyMove(const glm::vec2& moveBy)

const auto direction = currentGameObjectState_.position_ - prevPosition;

currentState_.viewAngle_ = glm::atan(direction.y, direction.x);

sprite_.Rotate(currentState_.viewAngle_);
if (glm::length(direction) > 0.0f)
{
currentState_.viewAngle_ = glm::atan(direction.y, direction.x);
sprite_.Rotate(currentState_.viewAngle_);
}
}

Move(moveBy);
Expand Down

0 comments on commit 3e4cb9d

Please sign in to comment.