diff options
| author | oy <Tom_Adams@web.de> | 2011-07-30 18:08:24 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-07-30 18:08:24 +0200 |
| commit | 7db6d1e0567ee439e67c83a0ef670db9b419cfb6 (patch) | |
| tree | 2c571ad40afd8f784bee6c5fdeeba4ab8d2bb6a9 /src/game/gamecore.cpp | |
| parent | b3e8506f20ac42902e575c4522502da94bace3ed (diff) | |
| download | zcatch-7db6d1e0567ee439e67c83a0ef670db9b419cfb6.tar.gz zcatch-7db6d1e0567ee439e67c83a0ef670db9b419cfb6.zip | |
fixed problem with player collision. Closes #722
Diffstat (limited to 'src/game/gamecore.cpp')
| -rw-r--r-- | src/game/gamecore.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index d2a1652c..af086df2 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -362,35 +362,37 @@ void CCharacterCore::Move() m_Vel.x = m_Vel.x*RampValue; - vec2 NewPos = m_Pos; + vec2 NewPos = m_Pos; m_pCollision->MoveBox(&NewPos, &m_Vel, vec2(28.0f, 28.0f), 0); m_Vel.x = m_Vel.x*(1.0f/RampValue); if(m_pWorld && m_pWorld->m_Tuning.m_PlayerCollision) { - // check player collision - float Distance = distance(m_Pos, NewPos); - int End = Distance+1; - for(int i = 0; i < End; i++) - { - float a = i/Distance; - vec2 Pos = mix(m_Pos, NewPos, a); - for(int p = 0; p < MAX_CLIENTS; p++) - { - CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p]; - if(!pCharCore || pCharCore == this) - continue; - float D = distance(Pos, pCharCore->m_Pos); - if(D < 28.0f*1.25f && D > 0.0f) - { - if(a > 0.0f) - m_Pos = Pos; - else - m_Pos = NewPos; - return; - } - } + // check player collision + float Distance = distance(m_Pos, NewPos); + int End = Distance+1; + vec2 LastPos = m_Pos; + for(int i = 0; i < End; i++) + { + float a = i/Distance; + vec2 Pos = mix(m_Pos, NewPos, a); + for(int p = 0; p < MAX_CLIENTS; p++) + { + CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p]; + if(!pCharCore || pCharCore == this) + continue; + float D = distance(Pos, pCharCore->m_Pos); + if(D < 28.0f && D > 0.0f) + { + if(a > 0.0f) + m_Pos = LastPos; + else if(distance(NewPos, pCharCore->m_Pos) > D) + m_Pos = NewPos; + return; + } + } + LastPos = Pos; } } |