diff --git a/Trolleybus/Trolleybus/DrawingTrolleybus.cs b/Trolleybus/Trolleybus/DrawingTrolleybus.cs
index 07de4ba..d8532d6 100644
--- a/Trolleybus/Trolleybus/DrawingTrolleybus.cs
+++ b/Trolleybus/Trolleybus/DrawingTrolleybus.cs
@@ -68,11 +68,8 @@ namespace Trolleybus
/// Координата Y
public void SetPosition(int x, int y)
{
- if (x > _pictureWidth || y > _pictureHeight) {
- return;
- }
- _startPosX = x;
- _startPosY = y;
+ _startPosX = Math.Min(Math.Max(x, 0), _pictureWidth - _trolleybusWidth);
+ _startPosY = Math.Min(Math.Max(y, 0), _pictureHeight - _trolleybusHeight);
}
///
/// Изменение направления перемещения