public int checkedSpriteDistance(Sprite sprite, int steps) { int max = 0; switch (sprite.Direction) { case Direction.Down: max = Height * FieldSize - (sprite.Y + FieldSize); break; case Direction.Up: max = sprite.Y; break; case Direction.Right: max = Width * FieldSize - (sprite.X + FieldSize); break; case Direction.Left: max = sprite.X; break; } return Math.Min (steps, max); }
public int calculateResidualSteps(Sprite sprite) { switch (sprite.Direction) { case Direction.Up: return sprite.Y % FieldSize; case Direction.Down: return FieldSize - sprite.Y % FieldSize; case Direction.Right: return FieldSize - sprite.X % FieldSize; case Direction.Left: return sprite.X % FieldSize; default: return FieldSize; } }