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 cf458c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
14 changes: 3 additions & 11 deletions src/game/client/prediction/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,19 +706,11 @@ 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);
// hardest to understand
float CurrentDirectionalSpeed = dot(Direction, m_Core.m_Vel);
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 * (TempMaxSpeed - CurrentDirectionalSpeed);
else
TempVel += Direction * Force;
}
Expand Down
14 changes: 3 additions & 11 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,19 +1482,11 @@ 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);
// hardest to understand
float CurrentDirectionalSpeed = dot(Direction, m_Core.m_Vel);
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 * (TempMaxSpeed - CurrentDirectionalSpeed);
else
TempVel += Direction * Force;
}
Expand Down

0 comments on commit cf458c4

Please sign in to comment.