Skip to content

Commit

Permalink
Improve Player::UpdatePlayerBullets accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Sep 12, 2024
1 parent 6277864 commit e53e566
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void Player::UpdatePlayerBullets(Player *player)
vector.x = vector.x / vecLength + bullet->velocity.x;
vector.y = vector.y / vecLength + bullet->velocity.y;

vecLength = vector.VectorLength();
vecLength = vector.VectorLengthF64();

bullet->unk_134.y = ZUN_MIN(vecLength, 10.0f);

Expand All @@ -533,7 +533,7 @@ void Player::UpdatePlayerBullets(Player *player)
bullet->unk_134.y += 0.33333333f;
vector.x = bullet->velocity.x;
vector.y = bullet->velocity.y;
vecLength = vector.VectorLength();
vecLength = vector.VectorLengthF64();
bullet->velocity.x = vector.x * bullet->unk_134.y / vecLength;
bullet->velocity.y = vector.y * bullet->unk_134.y / vecLength;
}
Expand Down Expand Up @@ -568,6 +568,7 @@ void Player::UpdatePlayerBullets(Player *player)
bullet->sprite.scaleY = (bullet->position.y * 2) / 14.0f;

bullet->size.y = bullet->position.y * 2;
break;
}

bullet->MoveHorizontal(&bullet->position.x);
Expand Down
5 changes: 5 additions & 0 deletions src/ZunMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ struct ZunVec2
return sqrt(this->x * this->x + this->y * this->y);
}

f64 VectorLengthF64()
{
return (f64)this->VectorLength();
}

D3DXVECTOR2 *AsD3dXVec()
{
return (D3DXVECTOR2 *)this;
Expand Down

0 comments on commit e53e566

Please sign in to comment.