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

Method Tick

src/game/gamecore.cpp:189–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189void CCharacterCore::Tick(bool UseInput, bool DoDeferredTick)
190{
191 m_MoveRestrictions = m_pCollision->GetMoveRestrictions(UseInput ? IsSwitchActiveCb : nullptr, this, m_Pos);
192 m_TriggeredEvents = 0;
193
194 // get ground state
195 const bool Grounded = m_pCollision->CheckPoint(m_Pos.x + PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5) || m_pCollision->CheckPoint(m_Pos.x - PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5);
196 vec2 TargetDirection = normalize(vec2(m_Input.m_TargetX, m_Input.m_TargetY));
197
198 m_Vel.y += m_Tuning.m_Gravity;
199
200 float MaxSpeed = Grounded ? m_Tuning.m_GroundControlSpeed : m_Tuning.m_AirControlSpeed;
201 float Accel = Grounded ? m_Tuning.m_GroundControlAccel : m_Tuning.m_AirControlAccel;
202 float Friction = Grounded ? m_Tuning.m_GroundFriction : m_Tuning.m_AirFriction;
203
204 // handle input
205 if(UseInput)
206 {
207 m_Direction = m_Input.m_Direction;
208
209 // setup angle
210 float TmpAngle = std::atan2(m_Input.m_TargetY, m_Input.m_TargetX);
211 if(TmpAngle < -(pi / 2.0f))
212 {
213 m_Angle = (int)((TmpAngle + (2.0f * pi)) * 256.0f);
214 }
215 else
216 {
217 m_Angle = (int)(TmpAngle * 256.0f);
218 }
219
220 // Special jump cases:
221 // m_Jumps == -1: A tee may only make one ground jump. Second jumped bit is always set
222 // m_Jumps == 0: A tee may not make a jump. Second jumped bit is always set
223 // m_Jumps == 1: A tee may do either a ground jump or an air jump. Second jumped bit is set after the first jump
224 // The second jumped bit can be overridden by special tiles so that the tee can nevertheless jump.
225
226 // handle jump
227 if(m_Input.m_Jump)
228 {
229 if(!(m_Jumped & 1))
230 {
231 if(Grounded && (!(m_Jumped & 2) || m_Jumps != 0))
232 {
233 m_TriggeredEvents |= COREEVENT_GROUND_JUMP;
234 m_Vel.y = -m_Tuning.m_GroundJumpImpulse;
235 if(m_Jumps > 1)
236 {
237 m_Jumped |= 1;
238 }
239 else
240 {
241 m_Jumped |= 3;
242 }
243 m_JumpedTotal = 0;
244 }
245 else if(!(m_Jumped & 2))
246 {

Callers

nothing calls this directly

Calls 11

normalizeFunction · 0.85
SaturatedAddFunction · 0.85
distanceFunction · 0.85
closest_point_on_lineFunction · 0.85
lengthFunction · 0.85
CheckPointMethod · 0.80
IntersectLineTeleHookMethod · 0.80
RandomOr0Method · 0.80
CanKeepHookMethod · 0.80
GetMoveRestrictionsMethod · 0.45
CanCollideMethod · 0.45

Tested by

no test coverage detected