public void Update1(GameCommand command) { UpdateX(command); UpdateY(command); if (!ready && command.Start) { ready = true; World.PlaySound(GameSound.Ready); } if (!canMove) { CreateSmoke(); if (damageDuration > 0) { damageDuration--; } else { canMove = true; } } }
private void UpdateX(GameCommand command) { var acceleration = state == State.OnGround ? accelerationOnGround : accelerationInAir; if (command.Left == command.Right || !canMove) { vx = Utility.DecreaseAbs(vx, acceleration / 2); if (vx == 0) { walkingDistance = 0; } } else { if (command.Left) { if (vx == 0) { walkingDistance = distancePerAnimation; } vx = Utility.AddClampMin(vx, -acceleration, -maxMovingSpeed); direction = Direction.Left; if (vx < 0) { walkingDistance += Math.Abs(vx); } else { walkingDistance = 0; } } else if (command.Right) { if (vx == 0) { walkingDistance = distancePerAnimation; } vx = Utility.AddClampMax(vx, acceleration, maxMovingSpeed); direction = Direction.Right; if (vx > 0) { walkingDistance += Math.Abs(vx); } else { walkingDistance = 0; } } else { Debug.Assert(false); } } vx = Utility.ClampAbs(vx, maxSpeed); X += vx; if (Left < World.CameraLeft) { Left = World.CameraLeft; vx = 0; } if (Right > World.CameraRight) { Right = World.CameraRight; vx = 0; } if (walkingDistance > animationCount * distancePerAnimation) { walkingDistance -= animationCount * distancePerAnimation; } }