diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b8d7f9f..b942956 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -24,8 +24,9 @@ namespace WarmlyShip public void SetPosition(int x, int y, int width, int height) { - _startPosX = x; - _startPosY = y; + Random random = new Random(); + _startPosX = x < 0 || x > width ? random.Next(0, width) : x; + _startPosY = y < 0 || y > height ? random.Next(0, height) : y; _pictureWidth = width; _pictureHeight = height; }