MCPcopy Create free account
hub / github.com/ddnet/ddnet / Move

Method Move

src/game/gamecore.cpp:529–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529void CCharacterCore::Move()
530{
531 float RampValue = VelocityRamp(length(m_Vel) * 50, m_Tuning.m_VelrampStart, m_Tuning.m_VelrampRange, m_Tuning.m_VelrampCurvature);
532
533 m_Vel.x = m_Vel.x * RampValue;
534
535 vec2 NewPos = m_Pos;
536
537 vec2 OldVel = m_Vel;
538 bool Grounded = false;
539 m_pCollision->MoveBox(&NewPos, &m_Vel, PhysicalSizeVec2(),
540 vec2(m_Tuning.m_GroundElasticityX,
541 m_Tuning.m_GroundElasticityY),
542 &Grounded);
543
544 if(Grounded)
545 {
546 m_Jumped &= ~2;
547 m_JumpedTotal = 0;
548 }
549
550 m_Colliding = 0;
551 if(m_Vel.x < 0.001f && m_Vel.x > -0.001f)
552 {
553 if(OldVel.x > 0)
554 m_Colliding = 1;
555 else if(OldVel.x < 0)
556 m_Colliding = 2;
557 }
558 else
559 m_LeftWall = true;
560
561 m_Vel.x = m_Vel.x * (1.0f / RampValue);
562
563 if(m_pWorld && (m_Super || (m_Tuning.m_PlayerCollision && !m_CollisionDisabled && !m_Solo)))
564 {
565 // check player collision
566 float Distance = distance(m_Pos, NewPos);
567 if(Distance > 0)
568 {
569 int End = Distance + 1;
570 vec2 LastPos = m_Pos;
571 for(int i = 0; i < End; i++)
572 {
573 float a = i / Distance;
574 vec2 Pos = mix(m_Pos, NewPos, a);
575 for(int p = 0; p < MAX_CLIENTS; p++)
576 {
577 CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p];
578 if(!pCharCore || pCharCore == this)
579 continue;
580 if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || pCharCore->m_CollisionDisabled || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)))))
581 continue;
582 float D = distance(Pos, pCharCore->m_Pos);
583 if(D < PhysicalSize())
584 {
585 if(a > 0.0f)
586 m_Pos = LastPos;

Callers

nothing calls this directly

Calls 6

VelocityRampFunction · 0.85
lengthFunction · 0.85
distanceFunction · 0.85
mixFunction · 0.85
MoveBoxMethod · 0.80
CanCollideMethod · 0.45

Tested by

no test coverage detected