private static byte PredictPosition(byte previousPosition, byte position, byte speed, TimeSpan elapsed) { byte distance = SpeedPredictor.PredictDistance(speed, elapsed); int direction = Math.Sign(position - previousPosition); byte newPosition = ClampPosition(previousPosition + direction * distance); return(newPosition); }