Лабораторная работа№1
This commit is contained in:
parent
4ef5a5cac1
commit
18baaa5880
31
Project1/Project1.sln
Normal file
31
Project1/Project1.sln
Normal file
@ -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
|
135
Project1/Project1/Project1.vcxproj
Normal file
135
Project1/Project1/Project1.vcxproj
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{ab7ea6c4-e58f-4c10-a6d7-63d958f07d30}</ProjectGuid>
|
||||
<RootNamespace>Project1</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Source.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
Project1/Project1/Project1.vcxproj.filters
Normal file
22
Project1/Project1/Project1.vcxproj.filters
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Исходные файлы">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы заголовков">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Source.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
21
Project1/Project1/Source.c
Normal file
21
Project1/Project1/Source.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -63,6 +63,7 @@ public class DrawningAirFighter
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
@ -71,11 +72,27 @@ public class DrawningAirFighter
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user