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

Method MoverSpeed

src/game/collision.cpp:789–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

787}
788
789int CCollision::MoverSpeed(int x, int y, vec2 *pSpeed) const
790{
791 int Nx = std::clamp(x / 32, 0, m_Width - 1);
792 int Ny = std::clamp(y / 32, 0, m_Height - 1);
793 int Index = m_pTiles[Ny * m_Width + Nx].m_Index;
794
795 if(Index != TILE_CP && Index != TILE_CP_F)
796 {
797 return 0;
798 }
799
800 vec2 Target;
801 switch(m_pTiles[Ny * m_Width + Nx].m_Flags)
802 {
803 case ROTATION_0:
804 Target.x = 0.0f;
805 Target.y = -4.0f;
806 break;
807 case ROTATION_90:
808 Target.x = 4.0f;
809 Target.y = 0.0f;
810 break;
811 case ROTATION_180:
812 Target.x = 0.0f;
813 Target.y = 4.0f;
814 break;
815 case ROTATION_270:
816 Target.x = -4.0f;
817 Target.y = 0.0f;
818 break;
819 default:
820 Target = vec2(0.0f, 0.0f);
821 break;
822 }
823 if(Index == TILE_CP_F)
824 {
825 Target *= 4.0f;
826 }
827 *pSpeed = Target;
828 return Index;
829}
830
831int CCollision::GetPureMapIndex(float x, float y) const
832{

Callers 6

MoveMethod · 0.80
TickMethod · 0.80
TickMethod · 0.80
TickMethod · 0.80
MoveMethod · 0.80
TickMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected