From 496f946e45f0302cd3c0938770f68cbfe7f7b99d Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Tue, 20 Sep 2022 22:04:02 +0300
Subject: [PATCH 1/8] =?UTF-8?q?=D0=BF=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?=
=?UTF-8?q?=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?=
=?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B=20=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD?=
=?UTF-8?q?=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80=D1=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
AirFighter/AirFighter/DrawingAirFighter.cs | 5 ++---
AirFighter/AirFighter/EntityAirFighter.cs | 2 +-
AirFighter/AirFighter/FormAirFighter.cs | 4 +---
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/AirFighter/AirFighter/DrawingAirFighter.cs b/AirFighter/AirFighter/DrawingAirFighter.cs
index 94d1b4f..5d85573 100644
--- a/AirFighter/AirFighter/DrawingAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingAirFighter.cs
@@ -19,10 +19,9 @@ namespace AirFighter
private readonly int _airFighterWidth = 195;
private readonly int _airFighterHeight = 166;
- public void Init(int speed, float weight, Color bodyColor)
+ public DrawingAirFighter(int speed, float weight, Color bodyColor)
{
- AirFighter = new EntityAirFighter();
- AirFighter.Init(speed, weight, bodyColor);
+ AirFighter = new EntityAirFighter(speed, weight, bodyColor);
}
public void SetPosition(int x, int y, int width, int height)
diff --git a/AirFighter/AirFighter/EntityAirFighter.cs b/AirFighter/AirFighter/EntityAirFighter.cs
index f1d1eaa..6a2e3e9 100644
--- a/AirFighter/AirFighter/EntityAirFighter.cs
+++ b/AirFighter/AirFighter/EntityAirFighter.cs
@@ -14,7 +14,7 @@ namespace AirFighter
public float Step => Speed * 100 / Weight;
- public void Init(int speed, float weight, Color bodyColor)
+ public EntityAirFighter(int speed, float weight, Color bodyColor)
{
Random rnd = new();
diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs
index b33c0a6..4c3639b 100644
--- a/AirFighter/AirFighter/FormAirFighter.cs
+++ b/AirFighter/AirFighter/FormAirFighter.cs
@@ -13,9 +13,7 @@ namespace AirFighter
{
Random rnd = new();
- _airFighter = new DrawingAirFighter();
-
- _airFighter.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
+ _airFighter = new DrawingAirFighter(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBox.Width, pictureBox.Height);
--
2.25.1
From d229bc8f731cf52f3604d2897c1a58e951acbfe0 Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Wed, 21 Sep 2022 08:04:55 +0300
Subject: [PATCH 2/8] main commit
---
AirFighter/AirFighter/DrawingAirFighter.cs | 19 ++++-
.../AirFighter/DrawingModernAirFighter.cs | 79 +++++++++++++++++++
.../AirFighter/DrawingObjectAirFighter.cs | 35 ++++++++
.../AirFighter/EntityModernAirFighter.cs | 49 ++++++++++++
.../AirFighter/FormAirFighter.Designer.cs | 14 ++++
AirFighter/AirFighter/FormAirFighter.cs | 27 ++++++-
AirFighter/AirFighter/IDrawingObject.cs | 18 +++++
7 files changed, 234 insertions(+), 7 deletions(-)
create mode 100644 AirFighter/AirFighter/DrawingModernAirFighter.cs
create mode 100644 AirFighter/AirFighter/DrawingObjectAirFighter.cs
create mode 100644 AirFighter/AirFighter/EntityModernAirFighter.cs
create mode 100644 AirFighter/AirFighter/IDrawingObject.cs
diff --git a/AirFighter/AirFighter/DrawingAirFighter.cs b/AirFighter/AirFighter/DrawingAirFighter.cs
index 5d85573..00bdbf6 100644
--- a/AirFighter/AirFighter/DrawingAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingAirFighter.cs
@@ -8,10 +8,10 @@ namespace AirFighter
{
internal class DrawingAirFighter
{
- public EntityAirFighter AirFighter { get; private set; }
+ public EntityAirFighter AirFighter { get; protected set; }
- private float _startPosX;
- private float _startPosY;
+ protected float _startPosX;
+ protected float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
@@ -23,6 +23,12 @@ namespace AirFighter
{
AirFighter = new EntityAirFighter(speed, weight, bodyColor);
}
+ public DrawingAirFighter(int speed, float weight, Color bodyColor, int airFighterWidth, int airFighterHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _airFighterWidth = airFighterWidth;
+ _airFighterHeight = airFighterHeight;
+ }
public void SetPosition(int x, int y, int width, int height)
{
@@ -78,7 +84,12 @@ namespace AirFighter
}
- public void DrawTransport(Graphics g)
+
+ public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
+ {
+ return ( _startPosX, _startPosX + _airFighterWidth, _startPosY, _startPosY + _airFighterHeight );
+ }
+ public virtual void DrawTransport(Graphics g)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
{
diff --git a/AirFighter/AirFighter/DrawingModernAirFighter.cs b/AirFighter/AirFighter/DrawingModernAirFighter.cs
new file mode 100644
index 0000000..81ad6e7
--- /dev/null
+++ b/AirFighter/AirFighter/DrawingModernAirFighter.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ internal class DrawingModernAirFighter : DrawingAirFighter
+ {
+ public DrawingModernAirFighter(int speed, float weight, Color bodyColor, Color dopColor, bool dopWings, bool rockets, bool sportLine) :
+ base(speed, weight, bodyColor, 110, 60)
+ {
+ AirFighter = new EntityModernAirFighter(speed, weight, bodyColor, dopColor, dopWings,
+ rockets, sportLine);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (AirFighter is not EntityModernAirFighter sportCar)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush dopBrush = new SolidBrush(sportCar.DopColor);
+ if (sportCar.DopWings)
+ {
+ g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20);
+ g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, 20);
+ g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, 20, 40);
+ g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, 15);
+ g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, 15, 15);
+ g.FillEllipse(dopBrush, _startPosX + 90, _startPosY, 20, 20);
+ g.FillEllipse(dopBrush, _startPosX + 90, _startPosY + 40, 20, 20);
+ g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 10, 20,
+ 40);
+ g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 1, 15,
+ 15);
+ g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 45, 15,
+ 15);
+ g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
+ g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20);
+ g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, 40);
+ g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, 15);
+ g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, 14, 15);
+ g.FillEllipse(dopBrush, _startPosX, _startPosY, 20, 20);
+ g.FillEllipse(dopBrush, _startPosX, _startPosY + 40, 20, 20);
+ g.FillRectangle(dopBrush, _startPosX + 1, _startPosY + 10, 25,
+ 40);
+ g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 1, 15, 15);
+ g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 45, 15,
+ 15);
+ g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, 15);
+ g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, 39, 15);
+ g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 1, 40,
+ 15);
+ g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 45, 40,
+ 15);
+ }
+ _startPosX += 10;
+ _startPosY += 5;
+ base.DrawTransport(g);
+ _startPosX -= 10;
+ _startPosY -= 5;
+ if (sportCar.SportLine)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 75, _startPosY + 23, 25,
+ 15);
+ g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 23, 35,
+ 15);
+ g.FillRectangle(dopBrush, _startPosX, _startPosY + 23, 20, 15);
+ }
+ if (sportCar.Rockets)
+ {
+ g.FillRectangle(dopBrush, _startPosX, _startPosY + 5, 10, 50);
+ g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, 50);
+ }
+ }
+ }
+}
diff --git a/AirFighter/AirFighter/DrawingObjectAirFighter.cs b/AirFighter/AirFighter/DrawingObjectAirFighter.cs
new file mode 100644
index 0000000..fefe8a2
--- /dev/null
+++ b/AirFighter/AirFighter/DrawingObjectAirFighter.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ internal class DrawingObjectAirFighter
+ {
+ private DrawingAirFighter _airFighter = null;
+ public DrawingObjectAirFighter(DrawingAirFighter car)
+ {
+ _airFighter = car;
+ }
+ public float Step => _airFighter?.AirFighter?.Step ?? 0;
+ public (float Left, float Right, float Top, float Bottom)
+ GetCurrentPosition()
+ {
+ return _airFighter?.GetCurrentPosition() ?? default;
+ }
+ public void MoveObject(Direction direction)
+ {
+ _airFighter?.MoveTransport(direction);
+ }
+ public void SetObject(int x, int y, int width, int height)
+ {
+ _airFighter.SetPosition(x, y, width, height);
+ }
+ public void DrawningObject(Graphics g)
+ {
+ // TODO
+ }
+ }
+}
diff --git a/AirFighter/AirFighter/EntityModernAirFighter.cs b/AirFighter/AirFighter/EntityModernAirFighter.cs
new file mode 100644
index 0000000..4845793
--- /dev/null
+++ b/AirFighter/AirFighter/EntityModernAirFighter.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+// EntityModernAirFighter
+
+namespace AirFighter
+{
+ internal class EntityModernAirFighter : EntityAirFighter
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия обвеса
+ ///
+ public bool DopWings { get; private set; }
+ ///
+ /// Признак наличия антикрыла
+ ///
+ public bool Rockets { get; private set; }
+ ///
+ /// Признак наличия гоночной полосы
+ ///
+ public bool SportLine { get; private set; }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ /// Признак наличия гоночной полосы
+ public EntityModernAirFighter(int speed, float weight, Color bodyColor, Color
+ dopColor, bool dopWings, bool rockets, bool sportLine) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ DopWings = dopWings;
+ Rockets = rockets;
+ SportLine = sportLine;
+ }
+ }
+}
diff --git a/AirFighter/AirFighter/FormAirFighter.Designer.cs b/AirFighter/AirFighter/FormAirFighter.Designer.cs
index ff1bd69..d76f966 100644
--- a/AirFighter/AirFighter/FormAirFighter.Designer.cs
+++ b/AirFighter/AirFighter/FormAirFighter.Designer.cs
@@ -38,6 +38,7 @@
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -147,11 +148,23 @@
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(43, 20);
this.toolStripStatusLabelBodyColor.Text = "цвет:";
//
+ // button1
+ //
+ this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.button1.Location = new System.Drawing.Point(121, 389);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(148, 29);
+ this.button1.TabIndex = 7;
+ this.button1.Text = "create modern";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.CreateModernButton_Click);
+ //
// FormAirFighter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.button1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.RightButton);
this.Controls.Add(this.LeftButton);
@@ -181,5 +194,6 @@
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
+ private Button button1;
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs
index 4c3639b..84b87f5 100644
--- a/AirFighter/AirFighter/FormAirFighter.cs
+++ b/AirFighter/AirFighter/FormAirFighter.cs
@@ -9,6 +9,13 @@ namespace AirFighter
InitializeComponent();
}
+ private void SetData(DrawingAirFighter airFighter)
+ {
+ toolStripStatusLabelSpeed.Text = $": {_airFighter.AirFighter.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_airFighter.AirFighter.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": { _airFighter.AirFighter.BodyColor.Name}";
+ }
+
private void CreateButton_Click(object sender, EventArgs e)
{
Random rnd = new();
@@ -18,10 +25,24 @@ namespace AirFighter
_airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBox.Width, pictureBox.Height);
- toolStripStatusLabelSpeed.Text = $": {_airFighter.AirFighter.Speed}";
- toolStripStatusLabelWeight.Text = $": {_airFighter.AirFighter.Weight}";
- toolStripStatusLabelBodyColor.Text = $": { _airFighter.AirFighter.BodyColor.Name}";
+ SetData(_airFighter);
+ Draw();
+ }
+ private void CreateModernButton_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+
+ _airFighter = new DrawingModernAirFighter(rnd.Next(100, 300), 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)));
+
+
+ _airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBox.Width, pictureBox.Height);
+
+ SetData(_airFighter);
Draw();
}
diff --git a/AirFighter/AirFighter/IDrawingObject.cs b/AirFighter/AirFighter/IDrawingObject.cs
new file mode 100644
index 0000000..cdc5255
--- /dev/null
+++ b/AirFighter/AirFighter/IDrawingObject.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ internal interface IDrawningObject
+ {
+ public float Step { get; }
+ void SetObject(int x, int y, int width, int height);
+ void MoveObject(Direction direction);
+ void DrawningObject(Graphics g);
+ (float Left, float Right, float Top, float Bottom) GetCurrentPosition();
+ }
+
+}
--
2.25.1
From c60f61ba1871cb74602901bb47f7286ccc4a345e Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Tue, 4 Oct 2022 16:27:39 +0300
Subject: [PATCH 3/8] main commit
---
AirFighter/AirFighter/AbstractMap.cs | 162 +++++++++++++
AirFighter/AirFighter/Direction.cs | 1 +
AirFighter/AirFighter/DrawingAirFighter.cs | 14 +-
.../AirFighter/DrawingModernAirFighter.cs | 148 +++++++-----
.../AirFighter/DrawingObjectAirFighter.cs | 7 +-
AirFighter/AirFighter/FormAirFighter.cs | 2 +-
AirFighter/AirFighter/FormMap.Designer.cs | 215 ++++++++++++++++++
AirFighter/AirFighter/FormMap.cs | 111 +++++++++
AirFighter/AirFighter/FormMap.resx | 63 +++++
AirFighter/AirFighter/IDrawingObject.cs | 2 +-
AirFighter/AirFighter/MyMap.cs | 48 ++++
AirFighter/AirFighter/Program.cs | 2 +-
AirFighter/AirFighter/SimpleMap.cs | 54 +++++
13 files changed, 762 insertions(+), 67 deletions(-)
create mode 100644 AirFighter/AirFighter/AbstractMap.cs
create mode 100644 AirFighter/AirFighter/FormMap.Designer.cs
create mode 100644 AirFighter/AirFighter/FormMap.cs
create mode 100644 AirFighter/AirFighter/FormMap.resx
create mode 100644 AirFighter/AirFighter/MyMap.cs
create mode 100644 AirFighter/AirFighter/SimpleMap.cs
diff --git a/AirFighter/AirFighter/AbstractMap.cs b/AirFighter/AirFighter/AbstractMap.cs
new file mode 100644
index 0000000..c8d3134
--- /dev/null
+++ b/AirFighter/AirFighter/AbstractMap.cs
@@ -0,0 +1,162 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ internal abstract class AbstractMap
+ {
+ private IDrawingObject _drawningObject = null;
+ protected int[,] _map = null;
+ protected int _width;
+ protected int _height;
+ protected float _size_x;
+ protected float _size_y;
+ protected readonly Random _random = new();
+ protected readonly int _freeRoad = 0;
+ protected readonly int _barrier = 1;
+ public Bitmap CreateMap(int width, int height, IDrawingObject drawningObject)
+ {
+ _width = width;
+ _height = height;
+ _drawningObject = drawningObject;
+ GenerateMap();
+ while (!SetObjectOnMap())
+ {
+ GenerateMap();
+ }
+ return DrawMapWithObject();
+ }
+
+ private (int mapI, int mapJ) checkBarrier((float Left, float Right, float Top, float Bottom) rect)
+ {
+ for (int i = (int)(rect.Top / _size_y); i <= (int)(rect.Bottom / _size_y); ++i)
+ {
+ for (int j = (int)(rect.Left / _size_x); j <= (int)(rect.Right / _size_x); ++j)
+ {
+ if (_map[i, j] == _barrier) return (i, j);
+ }
+ }
+
+ return (-1, -1);
+ }
+ public Bitmap MoveObject(Direction direction)
+ {
+ // TODO проверка, что объект может переместится в требуемом
+
+ var position = _drawningObject.GetCurrentPosition();
+
+ float drawningWidth = position.Right - position.Left;
+ float drawningHeight = position.Bottom - position.Top;
+
+ if (direction == Direction.Left) position.Left -= _drawningObject.Step;
+ if (direction == Direction.Right) position.Left += _drawningObject.Step;
+ if (direction == Direction.Up) position.Top -= _drawningObject.Step;
+ if (direction == Direction.Down) position.Top += _drawningObject.Step;
+
+ position.Right = position.Left + drawningWidth;
+ position.Bottom = position.Top + drawningHeight;
+
+ var currentBarrier = checkBarrier(position);
+
+ if (currentBarrier.mapI == -1)
+ {
+ _drawningObject.MoveObject(direction);
+ }
+
+ else if (direction == Direction.Left)
+ position.Left = (currentBarrier.mapJ + 1) * _size_x + 1;
+
+ else if (direction == Direction.Right)
+ position.Left = currentBarrier.mapJ * _size_x - drawningWidth - 1;
+
+ else if (direction == Direction.Up)
+ position.Top = (currentBarrier.mapI + 1) * _size_y + 1;
+
+ else if (direction == Direction.Down)
+ position.Top = currentBarrier.mapI * _size_y - drawningHeight - 1;
+
+ if (currentBarrier.mapI != -1)
+ _drawningObject.SetObject((int)position.Left, (int)position.Top, _width, _height);
+
+ return DrawMapWithObject();
+ }
+ private bool SetObjectOnMap()
+ {
+ if (_drawningObject == null || _map == null)
+ {
+ return false;
+ }
+ int x = _random.Next(0, 10);
+ int y = _random.Next(0, 10);
+ _drawningObject.SetObject(x, y, _width, _height);
+ // TODO првоерка, что объект не "накладывается" на закрытые участки
+
+ var position = _drawningObject.GetCurrentPosition();
+ float drawningWidth = position.Right - position.Left;
+ float drawningHeight = position.Bottom - position.Top;
+
+ var currentBarrier = checkBarrier(position);
+ int minRowIndex = _map.GetLength(0);
+
+ while(currentBarrier.mapI != -1)
+ {
+ minRowIndex = currentBarrier.mapI < minRowIndex ? currentBarrier.mapI : minRowIndex;
+
+ position.Left = (currentBarrier.mapJ + 1) * _size_x + 1;
+ position.Right = position.Left + drawningWidth;
+
+ if(position.Right > _width)
+ {
+ position.Top = (minRowIndex + 1) * _size_y;
+ position.Bottom = position.Top + drawningHeight;
+
+ position.Left = 0;
+ position.Right = drawningWidth;
+
+ minRowIndex = _map.GetLength(0);
+ }
+
+ if (position.Bottom > _height) {
+ return false;
+ }
+
+ currentBarrier = checkBarrier(position);
+ }
+
+ _drawningObject.SetObject((int)position.Left, (int)position.Top, _width, _height);
+
+ return true;
+ }
+ private Bitmap DrawMapWithObject()
+ {
+ Bitmap bmp = new(_width, _height);
+ if (_drawningObject == null || _map == null)
+ {
+ return bmp;
+ }
+ Graphics gr = Graphics.FromImage(bmp);
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ if (_map[i, j] == _freeRoad)
+ {
+ DrawRoadPart(gr, i, j);
+ }
+ else if (_map[i, j] == _barrier)
+ {
+ DrawBarrierPart(gr, i, j);
+ }
+ }
+ }
+ _drawningObject.DrawningObject(gr);
+ return bmp;
+ }
+ protected abstract void GenerateMap();
+ protected abstract void DrawRoadPart(Graphics g, int i, int j);
+ protected abstract void DrawBarrierPart(Graphics g, int i, int j);
+ }
+}
diff --git a/AirFighter/AirFighter/Direction.cs b/AirFighter/AirFighter/Direction.cs
index 7e6647a..6ce5485 100644
--- a/AirFighter/AirFighter/Direction.cs
+++ b/AirFighter/AirFighter/Direction.cs
@@ -8,6 +8,7 @@ namespace AirFighter
{
internal enum Direction
{
+ None,
Up,
Right,
Left,
diff --git a/AirFighter/AirFighter/DrawingAirFighter.cs b/AirFighter/AirFighter/DrawingAirFighter.cs
index 00bdbf6..5580c95 100644
--- a/AirFighter/AirFighter/DrawingAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingAirFighter.cs
@@ -34,10 +34,8 @@ namespace AirFighter
{
if (width < _airFighterWidth || height < _airFighterHeight) return;
- if (_startPosX + _airFighterWidth > _pictureWidth) return;
- if (_startPosX < 0) return;
- if (_startPosY < 0) return;
- if (_startPosY + _airFighterHeight > _pictureHeight) return;
+ if (x + _airFighterWidth > width || x < 0) return;
+ if (y + _airFighterHeight > height || y < 0) return;
_startPosX = x;
_startPosY = y;
@@ -96,13 +94,13 @@ namespace AirFighter
return;
}
- Pen pen = new(AirFighter.BodyColor);
+ Pen pen = new(AirFighter.BodyColor, 2);
Brush brushBlack = new SolidBrush(AirFighter.BodyColor);
PointF[] front = {
- new(_startPosX + 160, _startPosY + 70),
+ new(_startPosX + 160, _startPosY + 69),
new(_startPosX + 195, _startPosY + 83),
- new(_startPosX + 160, _startPosY + 96)
+ new(_startPosX + 160, _startPosY + 97)
};
PointF[] tailTop = {
@@ -136,12 +134,12 @@ namespace AirFighter
new(_startPosX + 75, _startPosY + 96),
};
- g.FillPolygon(brushBlack, front);
g.DrawPolygon(pen, tailTop);
g.DrawPolygon(pen, tailBottom);
g.DrawPolygon(pen, wingTop);
g.DrawPolygon(pen, wingBottom);
g.DrawRectangle(pen, _startPosX, _startPosY + 70, 160, 26);
+ g.FillPolygon(brushBlack, front);
}
public void ChangeBorders(int width, int height)
diff --git a/AirFighter/AirFighter/DrawingModernAirFighter.cs b/AirFighter/AirFighter/DrawingModernAirFighter.cs
index 81ad6e7..019c9f2 100644
--- a/AirFighter/AirFighter/DrawingModernAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingModernAirFighter.cs
@@ -9,71 +9,113 @@ namespace AirFighter
internal class DrawingModernAirFighter : DrawingAirFighter
{
public DrawingModernAirFighter(int speed, float weight, Color bodyColor, Color dopColor, bool dopWings, bool rockets, bool sportLine) :
- base(speed, weight, bodyColor, 110, 60)
+ base(speed, weight, bodyColor, 195, 166)
{
AirFighter = new EntityModernAirFighter(speed, weight, bodyColor, dopColor, dopWings,
rockets, sportLine);
}
public override void DrawTransport(Graphics g)
{
- if (AirFighter is not EntityModernAirFighter sportCar)
+ if (AirFighter is not EntityModernAirFighter modernAirFighter)
{
return;
}
- Pen pen = new(Color.Black);
- Brush dopBrush = new SolidBrush(sportCar.DopColor);
- if (sportCar.DopWings)
+
+ Pen pen = new(modernAirFighter.DopColor);
+ Brush dopBrush = new SolidBrush(modernAirFighter.DopColor);
+
+ g.DrawRectangle(pen, _startPosX, _startPosY, 195, 166);
+
+ if (modernAirFighter.DopWings)
{
- g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20);
- g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, 20);
- g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, 20, 40);
- g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, 15);
- g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, 15, 15);
- g.FillEllipse(dopBrush, _startPosX + 90, _startPosY, 20, 20);
- g.FillEllipse(dopBrush, _startPosX + 90, _startPosY + 40, 20, 20);
- g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 10, 20,
- 40);
- g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 1, 15,
- 15);
- g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 45, 15,
- 15);
- g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
- g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20);
- g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, 40);
- g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, 15);
- g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, 14, 15);
- g.FillEllipse(dopBrush, _startPosX, _startPosY, 20, 20);
- g.FillEllipse(dopBrush, _startPosX, _startPosY + 40, 20, 20);
- g.FillRectangle(dopBrush, _startPosX + 1, _startPosY + 10, 25,
- 40);
- g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 1, 15, 15);
- g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 45, 15,
- 15);
- g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, 15);
- g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, 39, 15);
- g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 1, 40,
- 15);
- g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 45, 40,
- 15);
+ /*PointF[] topDopWing =
+ {
+ new(_startPosX + 75, _startPosY + 14),
+ new(_startPosX + 86, _startPosY + 14),
+ new(_startPosX + 75, _startPosY + 70),
+ new(_startPosX + 70, _startPosY + 70),
+ };*/
+
+/* PointF[] topDopWing =
+ {
+ new(_startPosX + 78, _startPosY + 56),
+ new(_startPosX + 75, _startPosY + 70),
+ new(_startPosX + 55, _startPosY + 70),
+ new(_startPosX + 55, _startPosY + 45),
+ //new(_startPosX + 60, _startPosY + 55),
+ };*/
+
+ PointF[] topDopWing =
+ {
+ new(_startPosX + 78, _startPosY + 56),
+ new(_startPosX + 75, _startPosY + 70),
+ new(_startPosX + 55, _startPosY + 50),
+ new(_startPosX + 60, _startPosY + 45),
+ };
+
+ PointF[] bottomDopWing =
+ {
+ new(_startPosX + 78, _startPosY + 110),
+ new(_startPosX + 75, _startPosY + 96),
+ new(_startPosX + 55, _startPosY + 116),
+ new(_startPosX + 60, _startPosY + 121),
+ };
+
+ g.FillPolygon(dopBrush, topDopWing);
+ g.FillPolygon(dopBrush, bottomDopWing);
}
- _startPosX += 10;
- _startPosY += 5;
+
+ if (modernAirFighter.Rockets)
+ {
+ PointF[] topRocket1 =
+ {
+ new(_startPosX + 100, _startPosY + 20),
+ new(_startPosX + 100, _startPosY + 30),
+ new(_startPosX + 112, _startPosY + 30),
+ new(_startPosX + 120, _startPosY + 25),
+ new(_startPosX + 112, _startPosY + 20)
+ };
+
+ PointF[] topRocket2 =
+ {
+ new(_startPosX + 100, _startPosY + 35),
+ new(_startPosX + 100, _startPosY + 45),
+ new(_startPosX + 112, _startPosY + 45),
+ new(_startPosX + 120, _startPosY + 40),
+ new(_startPosX + 112, _startPosY + 35)
+ };
+
+ PointF[] bottomRocket1 =
+ {
+ new(_startPosX + 100, _startPosY + 146),
+ new(_startPosX + 100, _startPosY + 136),
+ new(_startPosX + 112, _startPosY + 136),
+ new(_startPosX + 120, _startPosY + 141),
+ new(_startPosX + 112, _startPosY + 146)
+ };
+
+ PointF[] bottomRocket2 =
+ {
+ new(_startPosX + 100, _startPosY + 131),
+ new(_startPosX + 100, _startPosY + 121),
+ new(_startPosX + 112, _startPosY + 121),
+ new(_startPosX + 120, _startPosY + 126),
+ new(_startPosX + 112, _startPosY + 131)
+ };
+
+ g.FillPolygon(dopBrush, topRocket1);
+ g.FillPolygon(dopBrush, topRocket2);
+ g.FillPolygon(dopBrush, bottomRocket1);
+ g.FillPolygon(dopBrush, bottomRocket2);
+ }
+
+
+/* _startPosX += 10;
+ _startPosY += 5;*/
base.DrawTransport(g);
- _startPosX -= 10;
- _startPosY -= 5;
- if (sportCar.SportLine)
- {
- g.FillRectangle(dopBrush, _startPosX + 75, _startPosY + 23, 25,
- 15);
- g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 23, 35,
- 15);
- g.FillRectangle(dopBrush, _startPosX, _startPosY + 23, 20, 15);
- }
- if (sportCar.Rockets)
- {
- g.FillRectangle(dopBrush, _startPosX, _startPosY + 5, 10, 50);
- g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, 50);
- }
+/* _startPosX -= 10;
+ _startPosY -= 5;*/
+
}
}
}
diff --git a/AirFighter/AirFighter/DrawingObjectAirFighter.cs b/AirFighter/AirFighter/DrawingObjectAirFighter.cs
index fefe8a2..54a8912 100644
--- a/AirFighter/AirFighter/DrawingObjectAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingObjectAirFighter.cs
@@ -6,12 +6,12 @@ using System.Threading.Tasks;
namespace AirFighter
{
- internal class DrawingObjectAirFighter
+ internal class DrawingObjectAirFighter : IDrawingObject
{
private DrawingAirFighter _airFighter = null;
- public DrawingObjectAirFighter(DrawingAirFighter car)
+ public DrawingObjectAirFighter(DrawingAirFighter airFighter)
{
- _airFighter = car;
+ _airFighter = airFighter;
}
public float Step => _airFighter?.AirFighter?.Step ?? 0;
public (float Left, float Right, float Top, float Bottom)
@@ -30,6 +30,7 @@ namespace AirFighter
public void DrawningObject(Graphics g)
{
// TODO
+ _airFighter.DrawTransport(g);
}
}
}
diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs
index 84b87f5..ea34367 100644
--- a/AirFighter/AirFighter/FormAirFighter.cs
+++ b/AirFighter/AirFighter/FormAirFighter.cs
@@ -8,7 +8,7 @@ namespace AirFighter
{
InitializeComponent();
}
-
+
private void SetData(DrawingAirFighter airFighter)
{
toolStripStatusLabelSpeed.Text = $": {_airFighter.AirFighter.Speed}";
diff --git a/AirFighter/AirFighter/FormMap.Designer.cs b/AirFighter/AirFighter/FormMap.Designer.cs
new file mode 100644
index 0000000..fece72c
--- /dev/null
+++ b/AirFighter/AirFighter/FormMap.Designer.cs
@@ -0,0 +1,215 @@
+namespace AirFighter
+{
+ partial class FormMap
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.CreateButton = new System.Windows.Forms.Button();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.DownButton = new System.Windows.Forms.Button();
+ this.UpButton = new System.Windows.Forms.Button();
+ this.LeftButton = new System.Windows.Forms.Button();
+ this.RightButton = new System.Windows.Forms.Button();
+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.button1 = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.statusStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // CreateButton
+ //
+ this.CreateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.CreateButton.Location = new System.Drawing.Point(12, 390);
+ this.CreateButton.Name = "CreateButton";
+ this.CreateButton.Size = new System.Drawing.Size(94, 29);
+ this.CreateButton.TabIndex = 0;
+ this.CreateButton.Text = "create";
+ this.CreateButton.UseVisualStyleBackColor = true;
+ this.CreateButton.Click += new System.EventHandler(this.CreateButton_Click);
+ //
+ // pictureBox
+ //
+ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBox.Location = new System.Drawing.Point(0, 0);
+ this.pictureBox.Name = "pictureBox";
+ this.pictureBox.Size = new System.Drawing.Size(800, 450);
+ this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ this.pictureBox.Resize += new System.EventHandler(this.PictureBox_Resize);
+ //
+ // DownButton
+ //
+ this.DownButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.DownButton.BackgroundImage = global::AirFighter.Properties.Resources.down;
+ this.DownButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.DownButton.Location = new System.Drawing.Point(727, 389);
+ this.DownButton.Name = "DownButton";
+ this.DownButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
+ this.DownButton.Size = new System.Drawing.Size(30, 30);
+ this.DownButton.TabIndex = 2;
+ this.DownButton.UseVisualStyleBackColor = true;
+ this.DownButton.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // UpButton
+ //
+ this.UpButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.UpButton.BackgroundImage = global::AirFighter.Properties.Resources.up;
+ this.UpButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.UpButton.Location = new System.Drawing.Point(727, 354);
+ this.UpButton.Name = "UpButton";
+ this.UpButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
+ this.UpButton.Size = new System.Drawing.Size(30, 30);
+ this.UpButton.TabIndex = 3;
+ this.UpButton.UseVisualStyleBackColor = true;
+ this.UpButton.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // LeftButton
+ //
+ this.LeftButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.LeftButton.BackgroundImage = global::AirFighter.Properties.Resources.left;
+ this.LeftButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.LeftButton.Location = new System.Drawing.Point(691, 389);
+ this.LeftButton.Name = "LeftButton";
+ this.LeftButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
+ this.LeftButton.Size = new System.Drawing.Size(30, 30);
+ this.LeftButton.TabIndex = 4;
+ this.LeftButton.UseVisualStyleBackColor = true;
+ this.LeftButton.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // RightButton
+ //
+ this.RightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.RightButton.BackgroundImage = global::AirFighter.Properties.Resources.right;
+ this.RightButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.RightButton.Location = new System.Drawing.Point(763, 389);
+ this.RightButton.Name = "RightButton";
+ this.RightButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
+ this.RightButton.Size = new System.Drawing.Size(30, 30);
+ this.RightButton.TabIndex = 5;
+ this.RightButton.UseVisualStyleBackColor = true;
+ this.RightButton.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabelSpeed,
+ this.toolStripStatusLabelWeight,
+ this.toolStripStatusLabelBodyColor});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 424);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(800, 26);
+ this.statusStrip1.TabIndex = 6;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // toolStripStatusLabelSpeed
+ //
+ this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
+ this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(74, 20);
+ this.toolStripStatusLabelSpeed.Text = "скорость:";
+ //
+ // toolStripStatusLabelWeight
+ //
+ this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
+ this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(35, 20);
+ this.toolStripStatusLabelWeight.Text = "вес:";
+ //
+ // toolStripStatusLabelBodyColor
+ //
+ this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
+ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(43, 20);
+ this.toolStripStatusLabelBodyColor.Text = "цвет:";
+ //
+ // button1
+ //
+ this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.button1.Location = new System.Drawing.Point(121, 389);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(148, 29);
+ this.button1.TabIndex = 7;
+ this.button1.Text = "create modern";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.CreateModernButton_Click);
+ //
+ // comboBoxSelectorMap
+ //
+ this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxSelectorMap.FormattingEnabled = true;
+ this.comboBoxSelectorMap.Items.AddRange(new object[] {
+ "простая карта",
+ "моя карта"});
+ this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(150, 28);
+ this.comboBoxSelectorMap.TabIndex = 8;
+ this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
+ //
+ // FormMap
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.comboBoxSelectorMap);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.statusStrip1);
+ this.Controls.Add(this.RightButton);
+ this.Controls.Add(this.LeftButton);
+ this.Controls.Add(this.UpButton);
+ this.Controls.Add(this.DownButton);
+ this.Controls.Add(this.CreateButton);
+ this.Controls.Add(this.pictureBox);
+ this.Name = "FormMap";
+ this.Text = "Form1";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Button CreateButton;
+ private PictureBox pictureBox;
+ private Button DownButton;
+ private Button UpButton;
+ private Button LeftButton;
+ private Button RightButton;
+ private StatusStrip statusStrip1;
+ private ToolStripStatusLabel toolStripStatusLabelSpeed;
+ private ToolStripStatusLabel toolStripStatusLabelWeight;
+ private ToolStripStatusLabel toolStripStatusLabelBodyColor;
+ private Button button1;
+ private ComboBox comboBoxSelectorMap;
+ }
+}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMap.cs b/AirFighter/AirFighter/FormMap.cs
new file mode 100644
index 0000000..42ca010
--- /dev/null
+++ b/AirFighter/AirFighter/FormMap.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace AirFighter
+{
+ public partial class FormMap : Form
+ {
+ private DrawingAirFighter _airFighter;
+ private AbstractMap _abstractMap;
+
+ public FormMap()
+ {
+ InitializeComponent();
+ _abstractMap = new SimpleMap();
+ }
+
+
+ private void SetData(DrawingAirFighter airFighter)
+ {
+ toolStripStatusLabelSpeed.Text = $"Скорость: {_airFighter.AirFighter.Speed}";
+ toolStripStatusLabelWeight.Text = $"Вес: {_airFighter.AirFighter.Weight}";
+ toolStripStatusLabelBodyColor.Text = $"Цвет: { _airFighter.AirFighter.BodyColor.Name}";
+
+ pictureBox.Image = _abstractMap.CreateMap(pictureBox.Width, pictureBox.Height, new DrawingObjectAirFighter(_airFighter));
+ }
+
+ private void CreateButton_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+
+ _airFighter = new DrawingAirFighter(rnd.Next(100, 300), rnd.Next(1000, 2000),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+
+ SetData(_airFighter);
+ }
+
+ private void CreateModernButton_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+
+ _airFighter = new DrawingModernAirFighter(rnd.Next(100, 300), 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)));
+
+
+ SetData(_airFighter);
+ }
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ Direction dir = Direction.None;
+ switch (name)
+ {
+ case "UpButton":
+ dir = Direction.Up;
+ break;
+ case "DownButton":
+ dir = Direction.Down;
+ break;
+ case "LeftButton":
+ dir = Direction.Left;
+ break;
+ case "RightButton":
+ dir = Direction.Right;
+ break;
+ }
+ pictureBox.Image = _abstractMap?.MoveObject(dir);
+
+ }
+
+ private void PictureBox_Resize(object sender, EventArgs e)
+ {
+ _airFighter?.ChangeBorders(pictureBox.Width, pictureBox.Height);
+ }
+
+
+ public void Draw()
+ {
+ if (pictureBox.Width == 0 || pictureBox.Height == 0) return;
+ Bitmap bmp = new(pictureBox.Width, pictureBox.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _airFighter?.DrawTransport(gr);
+ pictureBox.Image = bmp;
+ }
+
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "простая карта":
+ _abstractMap = new SimpleMap();
+ break;
+ case "моя карта":
+ _abstractMap = new MyMap();
+ break;
+ }
+ }
+
+
+ }
+}
diff --git a/AirFighter/AirFighter/FormMap.resx b/AirFighter/AirFighter/FormMap.resx
new file mode 100644
index 0000000..5cb320f
--- /dev/null
+++ b/AirFighter/AirFighter/FormMap.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/AirFighter/AirFighter/IDrawingObject.cs b/AirFighter/AirFighter/IDrawingObject.cs
index cdc5255..ef278d8 100644
--- a/AirFighter/AirFighter/IDrawingObject.cs
+++ b/AirFighter/AirFighter/IDrawingObject.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AirFighter
{
- internal interface IDrawningObject
+ internal interface IDrawingObject
{
public float Step { get; }
void SetObject(int x, int y, int width, int height);
diff --git a/AirFighter/AirFighter/MyMap.cs b/AirFighter/AirFighter/MyMap.cs
new file mode 100644
index 0000000..b06218d
--- /dev/null
+++ b/AirFighter/AirFighter/MyMap.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ internal class MyMap : AbstractMap
+ {
+
+ ///
+ /// Цвет участка закрытого
+ ///
+ private readonly Brush barrierColor = new SolidBrush(Color.Black);
+ ///
+ /// Цвет участка открытого
+ ///
+ private readonly Brush roadColor = new SolidBrush(Color.Gray);
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, j * _size_x, i * _size_y, _size_x, _size_y);
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, j * _size_x, i * _size_y, _size_x, _size_y);
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[10, 10] {
+ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
+ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ };
+
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ }
+
+ }
+}
diff --git a/AirFighter/AirFighter/Program.cs b/AirFighter/AirFighter/Program.cs
index 61bec04..b613151 100644
--- a/AirFighter/AirFighter/Program.cs
+++ b/AirFighter/AirFighter/Program.cs
@@ -11,7 +11,7 @@ namespace AirFighter
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormAirFighter());
+ Application.Run(new FormMap());
}
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/SimpleMap.cs b/AirFighter/AirFighter/SimpleMap.cs
new file mode 100644
index 0000000..81618c5
--- /dev/null
+++ b/AirFighter/AirFighter/SimpleMap.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ internal class SimpleMap : AbstractMap
+ {
+
+ ///
+ /// Цвет участка закрытого
+ ///
+ private readonly Brush barrierColor = new SolidBrush(Color.Black);
+ ///
+ /// Цвет участка открытого
+ ///
+ private readonly Brush roadColor = new SolidBrush(Color.Gray);
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, j * _size_x, i * _size_y, _size_x, _size_y);
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, j * _size_x, i * _size_y, _size_x, _size_y);
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[100, 100];
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ int counter = 0;
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+ while (counter < 50)
+ {
+ int x = _random.Next(0, 100);
+ int y = _random.Next(0, 100);
+ if (_map[x, y] == _freeRoad)
+ {
+ _map[x, y] = _barrier;
+ counter++;
+ }
+ }
+ }
+
+ }
+}
--
2.25.1
From d9446d1c46ab3a8625fc345240c5aa7f92c6a2eb Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Tue, 4 Oct 2022 21:48:21 +0300
Subject: [PATCH 4/8] change MyMap and rename buttons
---
AirFighter/AirFighter/FormMap.Designer.cs | 4 +-
AirFighter/AirFighter/MyMap.cs | 59 +++++++++++++++++------
2 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/AirFighter/AirFighter/FormMap.Designer.cs b/AirFighter/AirFighter/FormMap.Designer.cs
index fece72c..7337f25 100644
--- a/AirFighter/AirFighter/FormMap.Designer.cs
+++ b/AirFighter/AirFighter/FormMap.Designer.cs
@@ -51,7 +51,7 @@
this.CreateButton.Name = "CreateButton";
this.CreateButton.Size = new System.Drawing.Size(94, 29);
this.CreateButton.TabIndex = 0;
- this.CreateButton.Text = "create";
+ this.CreateButton.Text = "создание";
this.CreateButton.UseVisualStyleBackColor = true;
this.CreateButton.Click += new System.EventHandler(this.CreateButton_Click);
//
@@ -156,7 +156,7 @@
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(148, 29);
this.button1.TabIndex = 7;
- this.button1.Text = "create modern";
+ this.button1.Text = "модификация";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.CreateModernButton_Click);
//
diff --git a/AirFighter/AirFighter/MyMap.cs b/AirFighter/AirFighter/MyMap.cs
index b06218d..3f50303 100644
--- a/AirFighter/AirFighter/MyMap.cs
+++ b/AirFighter/AirFighter/MyMap.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -13,6 +13,7 @@ namespace AirFighter
/// Цвет участка закрытого
///
private readonly Brush barrierColor = new SolidBrush(Color.Black);
+
///
/// Цвет участка открытого
///
@@ -27,22 +28,52 @@ namespace AirFighter
}
protected override void GenerateMap()
{
- _map = new int[10, 10] {
- { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
- { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- };
-
+ _map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
+
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+
+
+ for(int i = 0; i < 20; ++i)
+ {
+ int x = _random.Next(0, 100);
+ int y = _random.Next(0, 100);
+
+ GenerateMap(x, y, _random.Next(13, 23));
+ }
+
}
+ private void GenerateMap(int x, int y, int depth)
+ {
+ if (depth <= 0) return;
+ bool check = false;
+
+ while (!check)
+ {
+ int deltaX = _random.Next(-1, 2);
+ int deltaY = _random.Next(-1, 2);
+
+ if (x + deltaX < 0 || x + deltaX >= 100) continue;
+ if (y + deltaY < 0 || y + deltaY >= 100) continue;
+
+ if (_map[y + deltaY, x + deltaX] == _barrier) depth--;
+ x += deltaX;
+ y += deltaY;
+
+ _map[y, x] = _barrier;
+
+ check = true;
+ }
+
+ GenerateMap(x, y, depth - 1);
+ }
}
}
--
2.25.1
From e9d0046f62863d66c113ee859f3f449ca705727e Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Wed, 5 Oct 2022 07:53:54 +0300
Subject: [PATCH 5/8] rename buttons and delete extra modification
---
.../AirFighter/DrawingModernAirFighter.cs | 4 +--
.../AirFighter/EntityModernAirFighter.cs | 28 ++-----------------
.../AirFighter/FormAirFighter.Designer.cs | 4 +--
AirFighter/AirFighter/FormAirFighter.cs | 3 +-
AirFighter/AirFighter/FormMap.cs | 3 +-
5 files changed, 9 insertions(+), 33 deletions(-)
diff --git a/AirFighter/AirFighter/DrawingModernAirFighter.cs b/AirFighter/AirFighter/DrawingModernAirFighter.cs
index 019c9f2..6dd6c85 100644
--- a/AirFighter/AirFighter/DrawingModernAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingModernAirFighter.cs
@@ -8,11 +8,11 @@ namespace AirFighter
{
internal class DrawingModernAirFighter : DrawingAirFighter
{
- public DrawingModernAirFighter(int speed, float weight, Color bodyColor, Color dopColor, bool dopWings, bool rockets, bool sportLine) :
+ public DrawingModernAirFighter(int speed, float weight, Color bodyColor, Color dopColor, bool dopWings, bool rockets) :
base(speed, weight, bodyColor, 195, 166)
{
AirFighter = new EntityModernAirFighter(speed, weight, bodyColor, dopColor, dopWings,
- rockets, sportLine);
+ rockets);
}
public override void DrawTransport(Graphics g)
{
diff --git a/AirFighter/AirFighter/EntityModernAirFighter.cs b/AirFighter/AirFighter/EntityModernAirFighter.cs
index 4845793..52763bf 100644
--- a/AirFighter/AirFighter/EntityModernAirFighter.cs
+++ b/AirFighter/AirFighter/EntityModernAirFighter.cs
@@ -10,40 +10,18 @@ namespace AirFighter
{
internal class EntityModernAirFighter : EntityAirFighter
{
- ///
- /// Дополнительный цвет
- ///
public Color DopColor { get; private set; }
- ///
- /// Признак наличия обвеса
- ///
public bool DopWings { get; private set; }
- ///
- /// Признак наличия антикрыла
- ///
public bool Rockets { get; private set; }
- ///
- /// Признак наличия гоночной полосы
- ///
- public bool SportLine { get; private set; }
- ///
- /// Инициализация свойств
- ///
- /// Скорость
- /// Вес автомобиля
- /// Цвет кузова
- /// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
+
+
public EntityModernAirFighter(int speed, float weight, Color bodyColor, Color
- dopColor, bool dopWings, bool rockets, bool sportLine) :
+ dopColor, bool dopWings, bool rockets) :
base(speed, weight, bodyColor)
{
DopColor = dopColor;
DopWings = dopWings;
Rockets = rockets;
- SportLine = sportLine;
}
}
}
diff --git a/AirFighter/AirFighter/FormAirFighter.Designer.cs b/AirFighter/AirFighter/FormAirFighter.Designer.cs
index d76f966..8bf5034 100644
--- a/AirFighter/AirFighter/FormAirFighter.Designer.cs
+++ b/AirFighter/AirFighter/FormAirFighter.Designer.cs
@@ -50,7 +50,7 @@
this.CreateButton.Name = "CreateButton";
this.CreateButton.Size = new System.Drawing.Size(94, 29);
this.CreateButton.TabIndex = 0;
- this.CreateButton.Text = "create";
+ this.CreateButton.Text = "создание";
this.CreateButton.UseVisualStyleBackColor = true;
this.CreateButton.Click += new System.EventHandler(this.CreateButton_Click);
//
@@ -155,7 +155,7 @@
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(148, 29);
this.button1.TabIndex = 7;
- this.button1.Text = "create modern";
+ this.button1.Text = "модификация";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.CreateModernButton_Click);
//
diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs
index ea34367..c5b8019 100644
--- a/AirFighter/AirFighter/FormAirFighter.cs
+++ b/AirFighter/AirFighter/FormAirFighter.cs
@@ -36,8 +36,7 @@ namespace AirFighter
_airFighter = new DrawingModernAirFighter(rnd.Next(100, 300), 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)));
+ Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,2)));
_airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBox.Width, pictureBox.Height);
diff --git a/AirFighter/AirFighter/FormMap.cs b/AirFighter/AirFighter/FormMap.cs
index 42ca010..e2d4fcb 100644
--- a/AirFighter/AirFighter/FormMap.cs
+++ b/AirFighter/AirFighter/FormMap.cs
@@ -48,8 +48,7 @@ namespace AirFighter
_airFighter = new DrawingModernAirFighter(rnd.Next(100, 300), 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)));
+ Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData(_airFighter);
--
2.25.1
From 908ca82192002c6441febc0ffa7776d4fce20052 Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Wed, 5 Oct 2022 08:32:29 +0300
Subject: [PATCH 6/8] refactoring
---
.../AirFighter/DrawingModernAirFighter.cs | 24 ++-----------------
1 file changed, 2 insertions(+), 22 deletions(-)
diff --git a/AirFighter/AirFighter/DrawingModernAirFighter.cs b/AirFighter/AirFighter/DrawingModernAirFighter.cs
index 6dd6c85..c05a07e 100644
--- a/AirFighter/AirFighter/DrawingModernAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingModernAirFighter.cs
@@ -11,8 +11,7 @@ namespace AirFighter
public DrawingModernAirFighter(int speed, float weight, Color bodyColor, Color dopColor, bool dopWings, bool rockets) :
base(speed, weight, bodyColor, 195, 166)
{
- AirFighter = new EntityModernAirFighter(speed, weight, bodyColor, dopColor, dopWings,
- rockets);
+ AirFighter = new EntityModernAirFighter(speed, weight, bodyColor, dopColor, dopWings, rockets);
}
public override void DrawTransport(Graphics g)
{
@@ -28,22 +27,7 @@ namespace AirFighter
if (modernAirFighter.DopWings)
{
- /*PointF[] topDopWing =
- {
- new(_startPosX + 75, _startPosY + 14),
- new(_startPosX + 86, _startPosY + 14),
- new(_startPosX + 75, _startPosY + 70),
- new(_startPosX + 70, _startPosY + 70),
- };*/
-
-/* PointF[] topDopWing =
- {
- new(_startPosX + 78, _startPosY + 56),
- new(_startPosX + 75, _startPosY + 70),
- new(_startPosX + 55, _startPosY + 70),
- new(_startPosX + 55, _startPosY + 45),
- //new(_startPosX + 60, _startPosY + 55),
- };*/
+
PointF[] topDopWing =
{
@@ -110,11 +94,7 @@ namespace AirFighter
}
-/* _startPosX += 10;
- _startPosY += 5;*/
base.DrawTransport(g);
-/* _startPosX -= 10;
- _startPosY -= 5;*/
}
}
--
2.25.1
From 5fb60274de9ba09ac4674d7b01167f44a657f117 Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Wed, 5 Oct 2022 08:38:42 +0300
Subject: [PATCH 7/8] fix error
---
AirFighter/AirFighter/AbstractMap.cs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/AirFighter/AirFighter/AbstractMap.cs b/AirFighter/AirFighter/AbstractMap.cs
index c8d3134..35e2ad6 100644
--- a/AirFighter/AirFighter/AbstractMap.cs
+++ b/AirFighter/AirFighter/AbstractMap.cs
@@ -32,10 +32,12 @@ namespace AirFighter
private (int mapI, int mapJ) checkBarrier((float Left, float Right, float Top, float Bottom) rect)
{
- for (int i = (int)(rect.Top / _size_y); i <= (int)(rect.Bottom / _size_y); ++i)
+ for (int i = (int)(rect.Top / _size_y); i <= (int)(rect.Bottom / _size_y) && i < _map.GetLength(0); ++i)
{
- for (int j = (int)(rect.Left / _size_x); j <= (int)(rect.Right / _size_x); ++j)
+ for (int j = (int)(rect.Left / _size_x); j <= (int)(rect.Right / _size_x) && j < _map.GetLength(1); ++j)
{
+ if (j < 0) j = 0;
+ if (i < 0) i = 0;
if (_map[i, j] == _barrier) return (i, j);
}
}
@@ -56,6 +58,8 @@ namespace AirFighter
if (direction == Direction.Up) position.Top -= _drawningObject.Step;
if (direction == Direction.Down) position.Top += _drawningObject.Step;
+
+
position.Right = position.Left + drawningWidth;
position.Bottom = position.Top + drawningHeight;
--
2.25.1
From 7591ef9672c364b32e1d3c26a52fbd5ada18bb34 Mon Sep 17 00:00:00 2001
From: MaxKarme <91691525+MaxKarme@users.noreply.github.com>
Date: Wed, 5 Oct 2022 08:45:50 +0300
Subject: [PATCH 8/8] delete border
---
AirFighter/AirFighter/DrawingModernAirFighter.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/AirFighter/AirFighter/DrawingModernAirFighter.cs b/AirFighter/AirFighter/DrawingModernAirFighter.cs
index c05a07e..2fea1df 100644
--- a/AirFighter/AirFighter/DrawingModernAirFighter.cs
+++ b/AirFighter/AirFighter/DrawingModernAirFighter.cs
@@ -23,8 +23,6 @@ namespace AirFighter
Pen pen = new(modernAirFighter.DopColor);
Brush dopBrush = new SolidBrush(modernAirFighter.DopColor);
- g.DrawRectangle(pen, _startPosX, _startPosY, 195, 166);
-
if (modernAirFighter.DopWings)
{
--
2.25.1