Merge branch 'LabWork1' of http://student.git.athene.tech/Senju/PIbd-22_Tsukanova_I.V._AircraftCarrier_Base into LabWork1
This commit is contained in:
commit
8721d19621
@ -59,27 +59,13 @@ namespace AircraftCarrier
|
||||
/// <param name="height"></param>
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
|
||||
if (width < _warshipWidth)
|
||||
if (width >= x + _warshipWidth && height >= y + _warshipHeight && x >= 0 && y >= 0)
|
||||
{
|
||||
width = _warshipWidth;
|
||||
}
|
||||
if (height < _warshipHeight)
|
||||
{
|
||||
height = _warshipHeight;
|
||||
}
|
||||
if(x + _warshipWidth > width)
|
||||
{
|
||||
_startPosX -= x + _warshipWidth - width;
|
||||
}
|
||||
if (y + _warshipHeight > height)
|
||||
{
|
||||
_pictureHeight -= y + _warshipHeight - height;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения
|
||||
|
@ -23,7 +23,7 @@ namespace AircraftCarrier
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
Random rnd = new();
|
||||
_warship = new DrawingWarship();
|
||||
_warship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
|
Loading…
Reference in New Issue
Block a user