This commit is contained in:
rakhaliullov 2024-03-07 09:32:18 +03:00
parent 0b05f36492
commit a1ae8210cf
2 changed files with 11 additions and 4 deletions

BIN
Stormtrooper.rar Normal file

Binary file not shown.

View File

@ -12,7 +12,7 @@ namespace Stormtrooper;
public class DrawningStormtrooper
{
// Класс-сущность
public EntityStormtrooper? EntityStormtrooper { get; private set; }
public EntityStormtrooper? EntityStormtrooper { get; private set; } // объявление
// Ширина окна
@ -50,7 +50,7 @@ public class DrawningStormtrooper
public void Init(int speed, double weight, Color bodyColor, Color
additionalColor, bool rocket, bool bomb, bool wing)
{
EntityStormtrooper = new EntityStormtrooper();
EntityStormtrooper = new EntityStormtrooper(); // инициализация
EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor,rocket, bomb, wing);
_pictureWidth = null;
_pictureHeight = null;
@ -89,14 +89,21 @@ public class DrawningStormtrooper
return;
}
if (x < 0 || x + _drawningStormtrooperWidth > _pictureWidth || y < 0 || y + _drawningStormtrooperHeight > _pictureHeight)
if (x < 0 || x + _drawningStormtrooperWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningStormtrooperWidth;
_startPosY = _pictureHeight - _drawningStormtrooperHeight;
}
else
{
_startPosX = x;
}
if (y < 0 || y + _drawningStormtrooperHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningStormtrooperHeight;
}
else
{
_startPosY = y;
}
}