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

Method RenderPickup

src/game/client/components/items.cpp:139–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139void CItems::RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCurrent, bool IsPredicted, int Flags)
140{
141 int CurWeapon = std::clamp(pCurrent->m_Subtype, 0, NUM_WEAPONS - 1);
142 int QuadOffset = 2;
143 float IntraTick = IsPredicted ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy);
144 vec2 Pos = mix(vec2(pPrev->m_X, pPrev->m_Y), vec2(pCurrent->m_X, pCurrent->m_Y), IntraTick);
145 if(pCurrent->m_Type == POWERUP_HEALTH)
146 {
147 QuadOffset = m_PickupHealthOffset;
148 Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpritePickupHealth);
149 }
150 else if(pCurrent->m_Type == POWERUP_ARMOR)
151 {
152 QuadOffset = m_PickupArmorOffset;
153 Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpritePickupArmor);
154 }
155 else if(pCurrent->m_Type == POWERUP_WEAPON)
156 {
157 QuadOffset = m_aPickupWeaponOffset[CurWeapon];
158 Graphics()->TextureSet(GameClient()->m_GameSkin.m_aSpritePickupWeapons[CurWeapon]);
159 }
160 else if(pCurrent->m_Type == POWERUP_NINJA)
161 {
162 QuadOffset = m_PickupNinjaOffset;
163 if(Flags & PICKUPFLAG_ROTATE)
164 GameClient()->m_Effects.PowerupShine(Pos, vec2(18, 96), 1.0f);
165 else
166 GameClient()->m_Effects.PowerupShine(Pos, vec2(96, 18), 1.0f);
167
168 Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpritePickupNinja);
169 }
170 else if(pCurrent->m_Type >= POWERUP_ARMOR_SHOTGUN && pCurrent->m_Type <= POWERUP_ARMOR_LASER)
171 {
172 QuadOffset = m_aPickupWeaponArmorOffset[pCurrent->m_Type - POWERUP_ARMOR_SHOTGUN];
173 Graphics()->TextureSet(GameClient()->m_GameSkin.m_aSpritePickupWeaponArmor[pCurrent->m_Type - POWERUP_ARMOR_SHOTGUN]);
174 }
175 Graphics()->QuadsSetRotation(0);
176 Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
177
178 vec2 Scale = vec2(1, 1);
179 if(Flags & PICKUPFLAG_XFLIP)
180 Scale.x = -Scale.x;
181
182 if(Flags & PICKUPFLAG_YFLIP)
183 Scale.y = -Scale.y;
184
185 if(Flags & PICKUPFLAG_ROTATE)
186 {
187 Graphics()->QuadsSetRotation(90.f * (pi / 180));
188 std::swap(Scale.x, Scale.y);
189
190 if(pCurrent->m_Type == POWERUP_NINJA)
191 {
192 if(Flags & PICKUPFLAG_XFLIP)
193 Pos.y += 10.0f;
194 else
195 Pos.y -= 10.0f;
196 }

Callers

nothing calls this directly

Calls 13

mixFunction · 0.85
GraphicsFunction · 0.85
directionFunction · 0.85
PredIntraGameTickMethod · 0.80
IntraGameTickMethod · 0.80
TextureSetMethod · 0.80
PowerupShineMethod · 0.80
QuadsSetRotationMethod · 0.80
BaseInfoMethod · 0.80
ClientFunction · 0.50
SetColorMethod · 0.45

Tested by

no test coverage detected