итоговый CUMmit

This commit is contained in:
devil_1nc 2022-10-02 20:10:45 +04:00
parent 397a890de9
commit 5795b9c88a
3 changed files with 17 additions and 9 deletions

View File

@ -32,11 +32,16 @@ namespace ProjectPlane
}
public Bitmap MoveObject(Direction direction)
{
bool isMoveable = false;
int _objWidth = Convert.ToInt32(_drawingObject.GetCurrentPosition().Right / _size_x);
int _startX = Convert.ToInt32(_drawingObject.GetCurrentPosition().Left / _size_x);
int _startY = Convert.ToInt32(_drawingObject.GetCurrentPosition().Top / _size_y);
int _objHeight = Convert.ToInt32(_drawingObject.GetCurrentPosition().Bottom / _size_y);
bool isMoveable = true;
switch (direction)
{
case Direction.Right:
for (int i = _objWidth; i <= _objWidth + Convert.ToInt32(_drawingObject.Step / _size_x); i++)
for (int i = _startX; i <= _objWidth + Convert.ToInt32(_drawingObject.Step / _size_x); i++)
{
for (int j = _startY; j <= _objHeight; j++)
{
@ -50,7 +55,7 @@ namespace ProjectPlane
break;
case Direction.Left:
for (int i = _startX; i >= Convert.ToInt32(_drawingObject.Step / _size_x); i--)
for (int i = _startX; i >= _startX - Convert.ToInt32(_drawingObject.Step / _size_x); i--)
{
for (int j = _startY; j <= _objHeight; j++)
{
@ -66,7 +71,7 @@ namespace ProjectPlane
case Direction.Up:
for (int i = _startX; i <= _objWidth; i++)
{
for (int j = _startY; j >= Convert.ToInt32(_drawingObject.Step / _size_y); j--)
for (int j = _startY; j >= _startY - Convert.ToInt32(_drawingObject.Step / _size_y); j--)
{
if (_map[i, j] == _barrier)
{

View File

@ -32,11 +32,11 @@ namespace ProjectPlane
/// <summary>
/// Ширина отрисовки самолета
/// </summary>
private readonly int _planeWidth = 120;
private readonly int _planeWidth = 125;
/// <summary>
/// Высота отрисовки самолета
/// </summary>
private readonly int _planeHeight = 50;
private readonly int _planeHeight = 45;
/// <summary>
/// Инициализация свойств
/// </summary>
@ -110,6 +110,7 @@ namespace ProjectPlane
{
_startPosX -= Plane.Step;
}
else _startPosX = 0;
break;
//вверх
case Direction.Up:
@ -124,6 +125,7 @@ namespace ProjectPlane
{
_startPosY += Plane.Step;
}
else _startPosY = 0;
break;
}
}
@ -207,6 +209,7 @@ namespace ProjectPlane
g.FillRectangle(brBlack, _startPosX + 41, _startPosY + 28, 42, 4);
g.FillEllipse(brBlack, _startPosX + 39, _startPosY + 28, 4, 4);
g.FillEllipse(brBlack, _startPosX + 81, _startPosY + 28, 4, 4);
}
/// <summary>
/// Смена границ формы отрисовки
@ -234,7 +237,7 @@ namespace ProjectPlane
}
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _planeWidth, _startPosY + _planeHeight);
return (_startPosX, _startPosX + _planeWidth, _startPosY , _startPosY + _planeHeight);
}
}
}

View File

@ -58,7 +58,7 @@ namespace ProjectPlane
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
var plane = new DrawingPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
var plane = new DrawingPlane(rnd.Next(300, 400), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
SetData(plane);
}
@ -71,7 +71,7 @@ namespace ProjectPlane
private void buttonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
var _plane = new DrawingWarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000),
var _plane = new DrawingWarPlane(rnd.Next(300, 400), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));