diff --git a/Project1/Project1.sln b/Project1/Project1.sln new file mode 100644 index 0000000..449dbc7 --- /dev/null +++ b/Project1/Project1.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34525.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x64.ActiveCfg = Debug|x64 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x64.Build.0 = Debug|x64 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x86.ActiveCfg = Debug|Win32 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x86.Build.0 = Debug|Win32 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x64.ActiveCfg = Release|x64 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x64.Build.0 = Release|x64 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x86.ActiveCfg = Release|Win32 + {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CFB832FC-6360-4FE9-9C85-0C6C32CF4B4F} + EndGlobalSection +EndGlobal diff --git a/Project1/Project1/Project1.vcxproj b/Project1/Project1/Project1.vcxproj new file mode 100644 index 0000000..e154bc4 --- /dev/null +++ b/Project1/Project1/Project1.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {ab7ea6c4-e58f-4c10-a6d7-63d958f07d30} + Project1 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Project1/Project1/Project1.vcxproj.filters b/Project1/Project1/Project1.vcxproj.filters new file mode 100644 index 0000000..9327ccf --- /dev/null +++ b/Project1/Project1/Project1.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file diff --git a/Project1/Project1/Source.c b/Project1/Project1/Source.c new file mode 100644 index 0000000..edd2450 --- /dev/null +++ b/Project1/Project1/Source.c @@ -0,0 +1,21 @@ +#include + +void main() { + + for (int n = 1000; n < 10000; n++) { + for (int x = 1000; x < 10000; x++) { + int e = 0; + for (int y = 1000; y < 10000; y++) { + if ((15 * x + 200 * y) == n) { + e += 1; + printf("x = %d, y = %d, n = %d\n", x, y, n); + if (e == 4) { + printf("e = 4, x = %d, y = %d, n = %d\n", x, y, n); + printf("%d", n); + return; + } + } + } + } + } +} \ No newline at end of file diff --git a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs index f11c964..0ffc0bb 100644 --- a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs @@ -62,6 +62,7 @@ public class DrawningAirFighter _startPosX = null; _startPosY = null; } + /// /// Установка границ поля @@ -71,11 +72,27 @@ public class DrawningAirFighter /// public bool SetPictureSize(int width, int height) { - //TODO проверка, что объект "влезает" в размер поля - // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена - _pictureWidth = width; - _pictureHeight = height; - return true; + if (width > _drawningAirFlighterWidth && height > _drawningAirFlighterHeight) + { + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX != null && _startPosY != null) + { + if (_startPosX.Value < 0) _startPosX = 0; + if (_startPosY.Value < 0) _startPosY = 0; + if (_startPosX.Value + _drawningAirFlighterWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningAirFlighterWidth; + } + if (_startPosY.Value + _drawningAirFlighterHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningAirFlighterHeight; + } + } + + return true; + } + return false; } @@ -90,15 +107,27 @@ public class DrawningAirFighter { return; } + else + { + _startPosX = x; + _startPosY = y; + if (_startPosX.Value < 0) _startPosX = 0; + if (_startPosY.Value < 0) _startPosY = 0; + if (_startPosX.Value + _drawningAirFlighterWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningAirFlighterWidth; + } + if (_startPosY.Value + _drawningAirFlighterHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningAirFlighterHeight; + } + } - //TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы - // то надо изменить координаты, чтобы он оставался в этих границах - _startPosX = x; - _startPosY = y; } + /// /// Изменение направления перемещения /// diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs index b639398..a8105ec 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs @@ -45,7 +45,6 @@ pictureBoxAirFighter.Size = new Size(924, 557); pictureBoxAirFighter.TabIndex = 0; pictureBoxAirFighter.TabStop = false; - // // buttonCreate // @@ -67,6 +66,7 @@ buttonLeft.Size = new Size(35, 35); buttonLeft.TabIndex = 2; buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.ClientSizeChanged += FormAirFighter_SizeChanged; buttonLeft.Click += ButtonMove_Click; // // buttonUp @@ -79,6 +79,7 @@ buttonUp.Size = new Size(35, 35); buttonUp.TabIndex = 3; buttonUp.UseVisualStyleBackColor = true; + buttonUp.ClientSizeChanged += FormAirFighter_SizeChanged; buttonUp.Click += ButtonMove_Click; // // buttonDown @@ -91,6 +92,7 @@ buttonDown.Size = new Size(35, 35); buttonDown.TabIndex = 4; buttonDown.UseVisualStyleBackColor = true; + buttonDown.ClientSizeChanged += FormAirFighter_SizeChanged; buttonDown.Click += ButtonMove_Click; // // buttonRight @@ -103,6 +105,7 @@ buttonRight.Size = new Size(35, 35); buttonRight.TabIndex = 5; buttonRight.UseVisualStyleBackColor = true; + buttonRight.ClientSizeChanged += FormAirFighter_SizeChanged; buttonRight.Click += ButtonMove_Click; // // FormAirFighter @@ -118,6 +121,7 @@ Controls.Add(pictureBoxAirFighter); Name = "FormAirFighter"; Text = "Истребитель"; + SizeChanged += FormAirFighter_SizeChanged; ((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).EndInit(); ResumeLayout(false); } diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs index f788568..291bc0f 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs @@ -13,6 +13,8 @@ namespace ProjectAirFighter public partial class FormAirFighter : Form { private DrawningAirFighter? _drawningAirFighter; + + private EntityAirFighter? _entityAirFighter; public FormAirFighter() { InitializeComponent(); @@ -20,6 +22,8 @@ namespace ProjectAirFighter private void Draw() { + if (_drawningAirFighter == null) return; + Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); Graphics gr = Graphics.FromImage(bmp); _drawningAirFighter.DrawTransport(gr); @@ -29,11 +33,14 @@ namespace ProjectAirFighter { Random random = new(); _drawningAirFighter = new DrawningAirFighter(); + _entityAirFighter = new EntityAirFighter(); + _drawningAirFighter.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); + _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); _drawningAirFighter.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); @@ -63,11 +70,26 @@ namespace ProjectAirFighter result = _drawningAirFighter.MoveTransport(DirectionType.Right); break; } - if (result) { Draw(); } + + + } + private void FormAirFighter_SizeChanged(object sender, EventArgs e) + { + if (_drawningAirFighter == null) return; + + + _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); + + + if (_drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height)) + { + Draw(); + } + }