private void updateSwinging(float a_deltaTime)
{
m_gravity = 0;
if (m_position.getLength() > 0)
{
if (KeyboardHandler.isKeyPressed(GameState.getRightKey()))
{
if ((m_swingSpeed > -MAXSWINGSPEED && !((m_rotate > Math.PI && m_rotate != 0) && m_swingSpeed <= 0 && m_swingSpeed >= -0.01f)) || (m_swingSpeed == 0 && m_rotate == Math.PI))
{
m_swingSpeed -= (500 * a_deltaTime) / m_position.getLength();
}
}
else if (KeyboardHandler.isKeyPressed(GameState.getLeftKey()))
{
if ((m_swingSpeed < MAXSWINGSPEED && !(m_rotate < Math.PI && m_swingSpeed >= 0 && m_swingSpeed <= 0.01f)) || (m_swingSpeed == 0 && m_rotate == Math.PI))
{
m_swingSpeed += (500 * a_deltaTime) / m_position.getLength();
}
}
else if (KeyboardHandler.isKeyPressed(GameState.getUpKey()))
{
m_position.setLength(Math.Max(m_position.getLength() - (200f * a_deltaTime), 50));
}
else if (KeyboardHandler.isKeyPressed(GameState.getDownKey()))
{
m_position.setLength(Math.Min(m_position.getLength() + (200f * a_deltaTime), m_rope.getLength()));
}
}
m_swingSpeed += (float)((Math.Cos(m_rope.getRotation()) * 3000 * a_deltaTime) / m_position.getLength());
m_swingSpeed *= 0.99f;
m_rope.addRotation(m_swingSpeed * a_deltaTime);
m_rope.update(Game.getInstance().getGameTime());
m_rotate = (m_rope.getRotation() - ((float)(Math.PI / 2.0))) % ((float)(Math.PI * 2.0));
m_position.setSlope(m_rope.getRotation());
if (m_swingSpeed > 1f)
{
if (!m_facingRight)
{
m_currentSwingingImage = "hero_swing_back";
}
else
{
m_currentSwingingImage = "hero_swing_forth";
}
}
else if (m_swingSpeed < -1f)
{
if (m_facingRight)
{
m_currentSwingingImage = "hero_swing_back";
}
else
{
m_currentSwingingImage = "hero_swing_forth";
}
}
else
{
m_currentSwingingImage = "hero_swing_still";
}
if (KeyboardHandler.keyClicked(GameState.getJumpKey()))
{
float t_force = m_swingSpeed * (m_position.getLength() + (m_img.getSize().Y / 2));
Vector2 t_inputForce = new Vector2();
if (KeyboardHandler.isKeyPressed(GameState.getUpKey()))
{
t_inputForce.Y -= 200;
}
if (KeyboardHandler.isKeyPressed(GameState.getDownKey()))
{
t_inputForce.Y += 200;
}
if (KeyboardHandler.isKeyPressed(GameState.getRightKey()))
{
t_inputForce.X += 200;
}
if (KeyboardHandler.isKeyPressed(GameState.getLeftKey()))
{
t_inputForce.X -= 200;
}
m_speed = new Vector2(t_force * (float)Math.Cos(m_rotate + Math.PI), t_force * (float)Math.Sin(m_rotate + Math.PI)) + t_inputForce;
m_currentState = State.Jumping;
}
}