Skip to content

Commit

Permalink
Merge branch 'feature/speedtiles2' of github.com:AssassinTee/ddnet in…
Browse files Browse the repository at this point in the history
…to feature/speedtiles2
  • Loading branch information
mwinkens committed Feb 11, 2025
2 parents b5a5c77 + 36c4af7 commit 3a7819a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions src/game/client/prediction/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,18 +707,14 @@ void CCharacter::HandleSkippableTiles(int Index)
else
{
float DotProduct = dot(Direction, m_Core.m_Vel);
// project current speed onto speedup direction
vec2 Projection = Direction * DotProduct; // direction has length one

// projection might point into opposite direction
float CurrentDirectionalSpeed = std::signbit(DotProduct) * length(Projection);
int Sign = DotProduct < 0 ? -1 : 1;
// the length of the projection of the player velocity on the direction is the dot product!
float CurrentDirectionalSpeed = Sign * DotProduct;
float TempMaxSpeed = MaxSpeed / 5.0f;
//float SpeedupSpeed = length(Direction * Force); // direction has length one
if(CurrentDirectionalSpeed + Force > TempMaxSpeed)
{
float NewForce = TempMaxSpeed - CurrentDirectionalSpeed;
TempVel += Direction * NewForce;
}
TempVel += Direction * (Force * TempMaxSpeed / (CurrentDirectionalSpeed + Force));
else
TempVel += Direction * Force;
}
Expand Down
12 changes: 4 additions & 8 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,18 +1483,14 @@ void CCharacter::HandleSkippableTiles(int Index)
else
{
float DotProduct = dot(Direction, m_Core.m_Vel);
// project current speed onto speedup direction
vec2 Projection = Direction * DotProduct; // direction has length one

// projection might point into opposite direction
float CurrentDirectionalSpeed = std::signbit(DotProduct) * length(Projection);
int Sign = DotProduct < 0 ? -1 : 1;
// the length of the projection of the player velocity on the direction is the dot product!
float CurrentDirectionalSpeed = Sign * DotProduct;
float TempMaxSpeed = MaxSpeed / 5.0f;
//float SpeedupSpeed = length(Direction * Force); // direction has length one
if(CurrentDirectionalSpeed + Force > TempMaxSpeed)
{
float NewForce = TempMaxSpeed - CurrentDirectionalSpeed;
TempVel += Direction * NewForce;
}
TempVel += Direction * (Force * TempMaxSpeed / (CurrentDirectionalSpeed + Force));
else
TempVel += Direction * Force;
}
Expand Down

0 comments on commit 3a7819a

Please sign in to comment.