From bbcdd491b058cb218a6a635c35affbb24ad87b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=96=D0=B5=D0=BB=D0=BE=D0=BD=D0=BA=D0=B8=D0=BD=20=D0=94?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=81?= Date: Wed, 22 Jan 2025 22:57:07 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 6 + Form1.Designer.cs | 215 +++++++++++++++++++++++++++++++ Form1.cs | 116 +++++++++++++++++ Form1.resx | 126 ++++++++++++++++++ Program.cs | 22 ++++ Properties/AssemblyInfo.cs | 36 ++++++ Properties/Resources.Designer.cs | 71 ++++++++++ Properties/Resources.resx | 117 +++++++++++++++++ Properties/Settings.Designer.cs | 30 +++++ Properties/Settings.settings | 7 + gameeee.csproj | 83 ++++++++++++ gameeee.sln | 25 ++++ 12 files changed, 854 insertions(+) create mode 100644 App.config create mode 100644 Form1.Designer.cs create mode 100644 Form1.cs create mode 100644 Form1.resx create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 gameeee.csproj create mode 100644 gameeee.sln diff --git a/App.config b/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..7c9d627 --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,215 @@ +namespace gameeee +{ + partial class Form1 + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.startButton = new System.Windows.Forms.Button(); + this.scoreLabel = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.timeLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.button9 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.timer2 = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // startButton + // + this.startButton.Location = new System.Drawing.Point(302, 9); + this.startButton.Name = "startButton"; + this.startButton.Size = new System.Drawing.Size(75, 23); + this.startButton.TabIndex = 27; + this.startButton.Text = "Начать"; + this.startButton.UseVisualStyleBackColor = true; + // + // scoreLabel + // + this.scoreLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.scoreLabel.Location = new System.Drawing.Point(260, 9); + this.scoreLabel.Name = "scoreLabel"; + this.scoreLabel.Size = new System.Drawing.Size(48, 23); + this.scoreLabel.TabIndex = 26; + this.scoreLabel.Text = "0"; + this.scoreLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label3 + // + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label3.Location = new System.Drawing.Point(188, 9); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(100, 23); + this.label3.TabIndex = 25; + this.label3.Text = "Очки"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // timeLabel + // + this.timeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.timeLabel.Location = new System.Drawing.Point(95, 9); + this.timeLabel.Name = "timeLabel"; + this.timeLabel.Size = new System.Drawing.Size(59, 23); + this.timeLabel.TabIndex = 24; + this.timeLabel.Text = "00:00"; + this.timeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label1 + // + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 23); + this.label1.TabIndex = 23; + this.label1.Text = "Время"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // button7 + // + this.button7.Location = new System.Drawing.Point(121, 135); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(43, 40); + this.button7.TabIndex = 22; + this.button7.UseVisualStyleBackColor = true; + // + // button8 + // + this.button8.Location = new System.Drawing.Point(72, 135); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(43, 40); + this.button8.TabIndex = 21; + this.button8.UseVisualStyleBackColor = true; + // + // button9 + // + this.button9.Location = new System.Drawing.Point(23, 135); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(43, 40); + this.button9.TabIndex = 20; + this.button9.UseVisualStyleBackColor = true; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(121, 89); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(43, 40); + this.button4.TabIndex = 19; + this.button4.UseVisualStyleBackColor = true; + // + // button5 + // + this.button5.Location = new System.Drawing.Point(72, 89); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(43, 40); + this.button5.TabIndex = 18; + this.button5.UseVisualStyleBackColor = true; + // + // button6 + // + this.button6.Location = new System.Drawing.Point(23, 89); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(43, 40); + this.button6.TabIndex = 17; + this.button6.UseVisualStyleBackColor = true; + // + // button3 + // + this.button3.Location = new System.Drawing.Point(121, 43); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(43, 40); + this.button3.TabIndex = 16; + this.button3.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(72, 43); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(43, 40); + this.button2.TabIndex = 15; + this.button2.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(23, 43); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(43, 40); + this.button1.TabIndex = 14; + this.button1.UseVisualStyleBackColor = true; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(389, 211); + this.Controls.Add(this.startButton); + this.Controls.Add(this.scoreLabel); + this.Controls.Add(this.label3); + this.Controls.Add(this.timeLabel); + this.Controls.Add(this.label1); + this.Controls.Add(this.button7); + this.Controls.Add(this.button8); + this.Controls.Add(this.button9); + this.Controls.Add(this.button4); + this.Controls.Add(this.button5); + this.Controls.Add(this.button6); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Button startButton; + private System.Windows.Forms.Label scoreLabel; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label timeLabel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.Button button9; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Timer timer2; + } +} + diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..78d6d3e --- /dev/null +++ b/Form1.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Runtime.Remoting.Channels; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace gameeee +{ + public partial class Form1 : Form + { + private Random random = new Random(); + private int score = 0; // Счет игрока + private int timeLeft = 60; // Время (секунд) + private int interval = 1000; // Интервал появления кнопки + private Timer gameTimer = new Timer(); // Таймер игры + private Timer buttonTimer = new Timer(); // Таймер для появления кнопок + + public Form1() + { + InitializeComponent(); + InitializeGame(); + } + + private void InitializeGame() + { + gameTimer.Interval = 1000; + gameTimer.Tick += GameTimer_Tick; + + buttonTimer.Interval = interval; + buttonTimer.Tick += ButtonTimer_Tick; + + startButton.Click += (sender, e) => + { + StartGame(); + }; + + foreach (Control control in this.Controls) + { + if (control is Button button && button.Name.StartsWith("button") && button != startButton) + { + button.Visible = false; + button.Click += CubeButton_Click; + } + } + } + + private void StartGame() + { + score = 0; + timeLeft = 60; + interval = 1000; + + scoreLabel.Text = "0"; + timeLabel.Text = "60"; + + buttonTimer.Interval = interval; + buttonTimer.Start(); + gameTimer.Start(); + } + + private void GameTimer_Tick(object sender, EventArgs e) + { + timeLeft--; + timeLabel.Text = $"{timeLeft}"; + + if (timeLeft <= 0) + { + gameTimer.Stop(); + buttonTimer.Stop(); + MessageBox.Show($"Игра окончена! Ваш счет: {score}", "Результат"); + } + } + + private void ButtonTimer_Tick(object sender, EventArgs e) + { + foreach (Control control in this.Controls) + { + if (control is Button button && button.Name.StartsWith("button") && button != startButton) + { + button.Visible = false; + } + } + + Button randomButton = this.Controls.Find($"button{random.Next(1, 10)}", true)[0] as Button; + randomButton.Location = new Point( + random.Next(this.ClientSize.Width - randomButton.Width), + random.Next(50, this.ClientSize.Height - randomButton.Height) + ); + randomButton.Visible = true; + } + + private void CubeButton_Click(object sender, EventArgs e) + { + Button clickedButton = sender as Button; + + if (clickedButton != null && clickedButton.Visible) + { + score++; + scoreLabel.Text = $"{score}"; + clickedButton.Visible = false; + + if (score % 5 == 0 && interval > 300) + { + interval -= 100; + buttonTimer.Interval = interval; + } + } + + } + } +} \ No newline at end of file diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..f94dad1 --- /dev/null +++ b/Form1.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 104, 17 + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..b698505 --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace gameeee +{ + internal static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b3916c7 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("gameeee")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("gameeee")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("2a445bf3-a174-43fe-9f23-b97b843b293a")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..0ad4d86 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + +namespace gameeee.Properties +{ + + + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("gameeee.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Переопределяет свойство CurrentUICulture текущего потока для всех + /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d8d81ff --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace gameeee.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/gameeee.csproj b/gameeee.csproj new file mode 100644 index 0000000..5418367 --- /dev/null +++ b/gameeee.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {2A445BF3-A174-43FE-9F23-B97B843B293A} + WinExe + gameeee + gameeee + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/gameeee.sln b/gameeee.sln new file mode 100644 index 0000000..8b7369b --- /dev/null +++ b/gameeee.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gameeee", "gameeee.csproj", "{2A445BF3-A174-43FE-9F23-B97B843B293A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A445BF3-A174-43FE-9F23-B97B843B293A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A445BF3-A174-43FE-9F23-B97B843B293A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A445BF3-A174-43FE-9F23-B97B843B293A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A445BF3-A174-43FE-9F23-B97B843B293A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51AAE872-99AB-496D-BC09-538F9FE8BD36} + EndGlobalSection +EndGlobal