diff --git a/Falling_Button.sln b/Falling_Button.sln new file mode 100644 index 0000000..3115ec6 --- /dev/null +++ b/Falling_Button.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Falling_Button", "Falling_Button\Falling_Button.csproj", "{FF7AE30D-AB99-4896-BB6F-17B6B57AEB00}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF7AE30D-AB99-4896-BB6F-17B6B57AEB00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF7AE30D-AB99-4896-BB6F-17B6B57AEB00}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF7AE30D-AB99-4896-BB6F-17B6B57AEB00}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF7AE30D-AB99-4896-BB6F-17B6B57AEB00}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E93D8040-2ECF-4EA0-A5E0-E0CE999DB991} + EndGlobalSection +EndGlobal diff --git a/Falling_Button/App.config b/Falling_Button/App.config new file mode 100644 index 0000000..b8e61f7 --- /dev/null +++ b/Falling_Button/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Falling_Button/Falling_Button.csproj b/Falling_Button/Falling_Button.csproj new file mode 100644 index 0000000..2d93510 --- /dev/null +++ b/Falling_Button/Falling_Button.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {FF7AE30D-AB99-4896-BB6F-17B6B57AEB00} + WinExe + Falling_Button + Falling_Button + v4.5.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + GameOver.cs + + + Form + + + MainForm.cs + + + Form + + + GamePlay.cs + + + + + Form + + + Title.cs + + + GameOver.cs + + + GamePlay.cs + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + Title.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/Falling_Button/GameOver.Designer.cs b/Falling_Button/GameOver.Designer.cs new file mode 100644 index 0000000..11dc464 --- /dev/null +++ b/Falling_Button/GameOver.Designer.cs @@ -0,0 +1,546 @@ +namespace Falling_Button +{ + partial class GameOver + { + /// + /// 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.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = 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.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.button9 = new System.Windows.Forms.Button(); + this.button10 = new System.Windows.Forms.Button(); + this.button11 = new System.Windows.Forms.Button(); + this.button12 = new System.Windows.Forms.Button(); + this.button13 = new System.Windows.Forms.Button(); + this.button14 = new System.Windows.Forms.Button(); + this.button15 = new System.Windows.Forms.Button(); + this.button16 = new System.Windows.Forms.Button(); + this.button17 = new System.Windows.Forms.Button(); + this.button18 = new System.Windows.Forms.Button(); + this.button19 = new System.Windows.Forms.Button(); + this.button20 = new System.Windows.Forms.Button(); + this.button21 = new System.Windows.Forms.Button(); + this.button22 = new System.Windows.Forms.Button(); + this.button23 = new System.Windows.Forms.Button(); + this.button24 = new System.Windows.Forms.Button(); + this.button25 = new System.Windows.Forms.Button(); + this.button26 = new System.Windows.Forms.Button(); + this.button27 = new System.Windows.Forms.Button(); + this.button28 = new System.Windows.Forms.Button(); + this.button29 = new System.Windows.Forms.Button(); + this.button30 = new System.Windows.Forms.Button(); + this.button31 = new System.Windows.Forms.Button(); + this.button32 = new System.Windows.Forms.Button(); + this.button33 = new System.Windows.Forms.Button(); + this.button34 = new System.Windows.Forms.Button(); + this.button35 = new System.Windows.Forms.Button(); + this.button36 = new System.Windows.Forms.Button(); + this.button37 = new System.Windows.Forms.Button(); + this.button_Restart = new System.Windows.Forms.Button(); + this.button_Exit = new System.Windows.Forms.Button(); + this.label_Score = new System.Windows.Forms.Label(); + this.button_ReturnToTitle = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(30, 29); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(64, 23); + this.button1.TabIndex = 0; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(10, 49); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(22, 123); + this.button2.TabIndex = 1; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + // + // button3 + // + this.button3.Location = new System.Drawing.Point(30, 173); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(64, 23); + this.button3.TabIndex = 2; + this.button3.Text = "button3"; + this.button3.UseVisualStyleBackColor = true; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(92, 106); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(23, 66); + this.button4.TabIndex = 3; + this.button4.Text = "button4"; + this.button4.UseVisualStyleBackColor = true; + // + // button5 + // + this.button5.Location = new System.Drawing.Point(49, 89); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(42, 23); + this.button5.TabIndex = 4; + this.button5.Text = "button5"; + this.button5.UseVisualStyleBackColor = true; + // + // button6 + // + this.button6.Location = new System.Drawing.Point(141, 29); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(46, 23); + this.button6.TabIndex = 5; + this.button6.Text = "button6"; + this.button6.UseVisualStyleBackColor = true; + // + // button7 + // + this.button7.Location = new System.Drawing.Point(121, 49); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(22, 147); + this.button7.TabIndex = 6; + this.button7.Text = "button7"; + this.button7.UseVisualStyleBackColor = true; + // + // button8 + // + this.button8.Location = new System.Drawing.Point(186, 49); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(22, 147); + this.button8.TabIndex = 7; + this.button8.Text = "button8"; + this.button8.UseVisualStyleBackColor = true; + // + // button9 + // + this.button9.Location = new System.Drawing.Point(141, 106); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(46, 23); + this.button9.TabIndex = 8; + this.button9.Text = "button9"; + this.button9.UseVisualStyleBackColor = true; + // + // button10 + // + this.button10.Location = new System.Drawing.Point(215, 29); + this.button10.Name = "button10"; + this.button10.Size = new System.Drawing.Size(24, 167); + this.button10.TabIndex = 9; + this.button10.Text = "button10"; + this.button10.UseVisualStyleBackColor = true; + // + // button11 + // + this.button11.Location = new System.Drawing.Point(239, 49); + this.button11.Name = "button11"; + this.button11.Size = new System.Drawing.Size(21, 24); + this.button11.TabIndex = 10; + this.button11.Text = "button11"; + this.button11.UseVisualStyleBackColor = true; + // + // button12 + // + this.button12.Location = new System.Drawing.Point(260, 67); + this.button12.Name = "button12"; + this.button12.Size = new System.Drawing.Size(23, 45); + this.button12.TabIndex = 11; + this.button12.Text = "button12"; + this.button12.UseVisualStyleBackColor = true; + // + // button13 + // + this.button13.Location = new System.Drawing.Point(283, 49); + this.button13.Name = "button13"; + this.button13.Size = new System.Drawing.Size(21, 24); + this.button13.TabIndex = 12; + this.button13.Text = "button13"; + this.button13.UseVisualStyleBackColor = true; + // + // button14 + // + this.button14.Location = new System.Drawing.Point(300, 27); + this.button14.Name = "button14"; + this.button14.Size = new System.Drawing.Size(24, 167); + this.button14.TabIndex = 13; + this.button14.Text = "button14"; + this.button14.UseVisualStyleBackColor = true; + // + // button15 + // + this.button15.Location = new System.Drawing.Point(330, 29); + this.button15.Name = "button15"; + this.button15.Size = new System.Drawing.Size(75, 23); + this.button15.TabIndex = 14; + this.button15.Text = "button15"; + this.button15.UseVisualStyleBackColor = true; + // + // button16 + // + this.button16.Location = new System.Drawing.Point(330, 50); + this.button16.Name = "button16"; + this.button16.Size = new System.Drawing.Size(22, 122); + this.button16.TabIndex = 15; + this.button16.Text = "button16"; + this.button16.UseVisualStyleBackColor = true; + // + // button17 + // + this.button17.Location = new System.Drawing.Point(330, 170); + this.button17.Name = "button17"; + this.button17.Size = new System.Drawing.Size(75, 23); + this.button17.TabIndex = 16; + this.button17.Text = "button17"; + this.button17.UseVisualStyleBackColor = true; + // + // button18 + // + this.button18.Location = new System.Drawing.Point(351, 99); + this.button18.Name = "button18"; + this.button18.Size = new System.Drawing.Size(54, 23); + this.button18.TabIndex = 17; + this.button18.Text = "button18"; + this.button18.UseVisualStyleBackColor = true; + // + // button19 + // + this.button19.Location = new System.Drawing.Point(453, 29); + this.button19.Name = "button19"; + this.button19.Size = new System.Drawing.Size(55, 23); + this.button19.TabIndex = 18; + this.button19.Text = "button19"; + this.button19.UseVisualStyleBackColor = true; + // + // button20 + // + this.button20.Location = new System.Drawing.Point(432, 49); + this.button20.Name = "button20"; + this.button20.Size = new System.Drawing.Size(25, 123); + this.button20.TabIndex = 19; + this.button20.Text = "button20"; + this.button20.UseVisualStyleBackColor = true; + // + // button21 + // + this.button21.Location = new System.Drawing.Point(453, 172); + this.button21.Name = "button21"; + this.button21.Size = new System.Drawing.Size(55, 23); + this.button21.TabIndex = 20; + this.button21.Text = "button21"; + this.button21.UseVisualStyleBackColor = true; + // + // button22 + // + this.button22.Location = new System.Drawing.Point(505, 50); + this.button22.Name = "button22"; + this.button22.Size = new System.Drawing.Size(25, 123); + this.button22.TabIndex = 21; + this.button22.Text = "button22"; + this.button22.UseVisualStyleBackColor = true; + // + // button23 + // + this.button23.Location = new System.Drawing.Point(536, 27); + this.button23.Name = "button23"; + this.button23.Size = new System.Drawing.Size(25, 124); + this.button23.TabIndex = 22; + this.button23.Text = "button23"; + this.button23.UseVisualStyleBackColor = true; + // + // button24 + // + this.button24.Location = new System.Drawing.Point(557, 149); + this.button24.Name = "button24"; + this.button24.Size = new System.Drawing.Size(25, 23); + this.button24.TabIndex = 23; + this.button24.Text = "button24"; + this.button24.UseVisualStyleBackColor = true; + // + // button25 + // + this.button25.Location = new System.Drawing.Point(579, 170); + this.button25.Name = "button25"; + this.button25.Size = new System.Drawing.Size(25, 23); + this.button25.TabIndex = 24; + this.button25.Text = "button25"; + this.button25.UseVisualStyleBackColor = true; + // + // button26 + // + this.button26.Location = new System.Drawing.Point(603, 150); + this.button26.Name = "button26"; + this.button26.Size = new System.Drawing.Size(25, 23); + this.button26.TabIndex = 25; + this.button26.Text = "button26"; + this.button26.UseVisualStyleBackColor = true; + // + // button27 + // + this.button27.Location = new System.Drawing.Point(629, 29); + this.button27.Name = "button27"; + this.button27.Size = new System.Drawing.Size(25, 124); + this.button27.TabIndex = 26; + this.button27.Text = "button27"; + this.button27.UseVisualStyleBackColor = true; + // + // button28 + // + this.button28.Location = new System.Drawing.Point(681, 99); + this.button28.Name = "button28"; + this.button28.Size = new System.Drawing.Size(54, 23); + this.button28.TabIndex = 30; + this.button28.Text = "button28"; + this.button28.UseVisualStyleBackColor = true; + // + // button29 + // + this.button29.Location = new System.Drawing.Point(660, 170); + this.button29.Name = "button29"; + this.button29.Size = new System.Drawing.Size(75, 23); + this.button29.TabIndex = 29; + this.button29.Text = "button29"; + this.button29.UseVisualStyleBackColor = true; + // + // button30 + // + this.button30.Location = new System.Drawing.Point(660, 50); + this.button30.Name = "button30"; + this.button30.Size = new System.Drawing.Size(22, 122); + this.button30.TabIndex = 28; + this.button30.Text = "button30"; + this.button30.UseVisualStyleBackColor = true; + // + // button31 + // + this.button31.Location = new System.Drawing.Point(660, 29); + this.button31.Name = "button31"; + this.button31.Size = new System.Drawing.Size(75, 23); + this.button31.TabIndex = 27; + this.button31.Text = "button31"; + this.button31.UseVisualStyleBackColor = true; + // + // button32 + // + this.button32.Location = new System.Drawing.Point(741, 27); + this.button32.Name = "button32"; + this.button32.Size = new System.Drawing.Size(75, 23); + this.button32.TabIndex = 31; + this.button32.Text = "button32"; + this.button32.UseVisualStyleBackColor = true; + // + // button33 + // + this.button33.Location = new System.Drawing.Point(741, 50); + this.button33.Name = "button33"; + this.button33.Size = new System.Drawing.Size(25, 143); + this.button33.TabIndex = 32; + this.button33.Text = "button33"; + this.button33.UseVisualStyleBackColor = true; + // + // button34 + // + this.button34.Location = new System.Drawing.Point(809, 49); + this.button34.Name = "button34"; + this.button34.Size = new System.Drawing.Size(23, 52); + this.button34.TabIndex = 33; + this.button34.Text = "button34"; + this.button34.UseVisualStyleBackColor = true; + // + // button35 + // + this.button35.Location = new System.Drawing.Point(764, 99); + this.button35.Name = "button35"; + this.button35.Size = new System.Drawing.Size(50, 23); + this.button35.TabIndex = 34; + this.button35.Text = "button35"; + this.button35.UseVisualStyleBackColor = true; + // + // button36 + // + this.button36.Location = new System.Drawing.Point(787, 120); + this.button36.Name = "button36"; + this.button36.Size = new System.Drawing.Size(27, 23); + this.button36.TabIndex = 35; + this.button36.Text = "button36"; + this.button36.UseVisualStyleBackColor = true; + // + // button37 + // + this.button37.Location = new System.Drawing.Point(809, 141); + this.button37.Name = "button37"; + this.button37.Size = new System.Drawing.Size(24, 53); + this.button37.TabIndex = 36; + this.button37.Text = "button37"; + this.button37.UseVisualStyleBackColor = true; + // + // button_Restart + // + this.button_Restart.Location = new System.Drawing.Point(331, 226); + this.button_Restart.Name = "button_Restart"; + this.button_Restart.Size = new System.Drawing.Size(195, 62); + this.button_Restart.TabIndex = 37; + this.button_Restart.Text = "Restart"; + this.button_Restart.UseVisualStyleBackColor = true; + this.button_Restart.Click += new System.EventHandler(this.button_Restart_Click); + // + // button_Exit + // + this.button_Exit.Location = new System.Drawing.Point(331, 294); + this.button_Exit.Name = "button_Exit"; + this.button_Exit.Size = new System.Drawing.Size(195, 62); + this.button_Exit.TabIndex = 38; + this.button_Exit.Text = "Exit"; + this.button_Exit.UseVisualStyleBackColor = true; + this.button_Exit.Click += new System.EventHandler(this.button_Exit_Click); + // + // label_Score + // + this.label_Score.AutoSize = true; + this.label_Score.Font = new System.Drawing.Font("宋体", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label_Score.Location = new System.Drawing.Point(369, 194); + this.label_Score.Name = "label_Score"; + this.label_Score.Size = new System.Drawing.Size(117, 28); + this.label_Score.TabIndex = 39; + this.label_Score.Text = "Score:0"; + // + // button_ReturnToTitle + // + this.button_ReturnToTitle.Location = new System.Drawing.Point(10, 329); + this.button_ReturnToTitle.Name = "button_ReturnToTitle"; + this.button_ReturnToTitle.Size = new System.Drawing.Size(198, 27); + this.button_ReturnToTitle.TabIndex = 40; + this.button_ReturnToTitle.Text = "Return to title"; + this.button_ReturnToTitle.UseVisualStyleBackColor = true; + this.button_ReturnToTitle.Click += new System.EventHandler(this.button_ReturnToTitle_Click); + // + // GameOver + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.SkyBlue; + this.ClientSize = new System.Drawing.Size(844, 370); + this.Controls.Add(this.button_ReturnToTitle); + this.Controls.Add(this.label_Score); + this.Controls.Add(this.button_Exit); + this.Controls.Add(this.button_Restart); + this.Controls.Add(this.button37); + this.Controls.Add(this.button36); + this.Controls.Add(this.button35); + this.Controls.Add(this.button34); + this.Controls.Add(this.button33); + this.Controls.Add(this.button32); + this.Controls.Add(this.button28); + this.Controls.Add(this.button29); + this.Controls.Add(this.button30); + this.Controls.Add(this.button31); + this.Controls.Add(this.button27); + this.Controls.Add(this.button26); + this.Controls.Add(this.button25); + this.Controls.Add(this.button24); + this.Controls.Add(this.button23); + this.Controls.Add(this.button22); + this.Controls.Add(this.button21); + this.Controls.Add(this.button20); + this.Controls.Add(this.button19); + this.Controls.Add(this.button18); + this.Controls.Add(this.button17); + this.Controls.Add(this.button16); + this.Controls.Add(this.button15); + this.Controls.Add(this.button14); + this.Controls.Add(this.button13); + this.Controls.Add(this.button12); + this.Controls.Add(this.button11); + this.Controls.Add(this.button10); + this.Controls.Add(this.button9); + this.Controls.Add(this.button8); + this.Controls.Add(this.button7); + this.Controls.Add(this.button6); + this.Controls.Add(this.button5); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "GameOver"; + this.Text = "GameOver"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.Button button9; + private System.Windows.Forms.Button button10; + private System.Windows.Forms.Button button11; + private System.Windows.Forms.Button button12; + private System.Windows.Forms.Button button13; + private System.Windows.Forms.Button button14; + private System.Windows.Forms.Button button15; + private System.Windows.Forms.Button button16; + private System.Windows.Forms.Button button17; + private System.Windows.Forms.Button button18; + private System.Windows.Forms.Button button19; + private System.Windows.Forms.Button button20; + private System.Windows.Forms.Button button21; + private System.Windows.Forms.Button button22; + private System.Windows.Forms.Button button23; + private System.Windows.Forms.Button button24; + private System.Windows.Forms.Button button25; + private System.Windows.Forms.Button button26; + private System.Windows.Forms.Button button27; + private System.Windows.Forms.Button button28; + private System.Windows.Forms.Button button29; + private System.Windows.Forms.Button button30; + private System.Windows.Forms.Button button31; + private System.Windows.Forms.Button button32; + private System.Windows.Forms.Button button33; + private System.Windows.Forms.Button button34; + private System.Windows.Forms.Button button35; + private System.Windows.Forms.Button button36; + private System.Windows.Forms.Button button37; + private System.Windows.Forms.Button button_Restart; + private System.Windows.Forms.Button button_Exit; + public System.Windows.Forms.Label label_Score;//private改成public + private System.Windows.Forms.Button button_ReturnToTitle; + } +} \ No newline at end of file diff --git a/Falling_Button/GameOver.cs b/Falling_Button/GameOver.cs new file mode 100644 index 0000000..a242f98 --- /dev/null +++ b/Falling_Button/GameOver.cs @@ -0,0 +1,47 @@ +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 Falling_Button +{ + public partial class GameOver : Form + { + public GameOver() + { + InitializeComponent(); + } + + private void button_Restart_Click(object sender, EventArgs e) + { + GamePlay gamePlayForm = new GamePlay(); + gamePlayForm.TopLevel = false; + gamePlayForm.Dock = DockStyle.Fill; + this.Parent.Controls.Add(gamePlayForm); + gamePlayForm.Show(); + gamePlayForm.Focus();//使该控件获取焦点 + this.Dispose(); + } + + private void button_Exit_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private void button_ReturnToTitle_Click(object sender, EventArgs e) + { + Title title = new Title(); + title.TopLevel = false; + title.Dock = DockStyle.Fill; + this.Parent.Controls.Add(title); + title.Show(); + title.Focus();//使该控件获取焦点 + this.Dispose(); + } + } +} diff --git a/Falling_Button/GameOver.resx b/Falling_Button/GameOver.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/Falling_Button/GameOver.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Falling_Button/GamePlay.Designer.cs b/Falling_Button/GamePlay.Designer.cs new file mode 100644 index 0000000..2d91d0a --- /dev/null +++ b/Falling_Button/GamePlay.Designer.cs @@ -0,0 +1,96 @@ +namespace Falling_Button +{ + partial class GamePlay + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.button_Player = new System.Windows.Forms.Button(); + this.timer_UpdateGame = new System.Windows.Forms.Timer(this.components); + this.timer_GenerateLongButton = new System.Windows.Forms.Timer(this.components); + this.label_Score = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button_Player + // + this.button_Player.BackColor = System.Drawing.Color.DarkGreen; + this.button_Player.Location = new System.Drawing.Point(46, 119); + this.button_Player.Name = "button_Player"; + this.button_Player.Size = new System.Drawing.Size(32, 32); + this.button_Player.TabIndex = 0; + this.button_Player.UseVisualStyleBackColor = false; + this.button_Player.Click += new System.EventHandler(this.button_Player_Click); + // + // timer_UpdateGame + // + this.timer_UpdateGame.Enabled = true; + this.timer_UpdateGame.Interval = 1; + this.timer_UpdateGame.Tick += new System.EventHandler(this.timer_UpdateGame_Tick); + // + // timer_GenerateLongButton + // + this.timer_GenerateLongButton.Enabled = true; + this.timer_GenerateLongButton.Interval = 3000; + this.timer_GenerateLongButton.Tick += new System.EventHandler(this.timer_GenerateLongButton_Tick); + // + // label_Score + // + this.label_Score.AutoSize = true; + this.label_Score.BackColor = System.Drawing.Color.SkyBlue; + this.label_Score.Font = new System.Drawing.Font("宋体", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label_Score.Location = new System.Drawing.Point(12, 9); + this.label_Score.Name = "label_Score"; + this.label_Score.Size = new System.Drawing.Size(117, 28); + this.label_Score.TabIndex = 1; + this.label_Score.Text = "Score:0"; + // + // GamePlay + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.SkyBlue; + this.ClientSize = new System.Drawing.Size(639, 379); + this.Controls.Add(this.button_Player); + this.Controls.Add(this.label_Score); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "GamePlay"; + this.Text = "GamePlay"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GamePlay_KeyDown); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.GamePlay_MouseDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button_Player; + private System.Windows.Forms.Timer timer_UpdateGame; + private System.Windows.Forms.Timer timer_GenerateLongButton; + private System.Windows.Forms.Label label_Score; + } +} \ No newline at end of file diff --git a/Falling_Button/GamePlay.cs b/Falling_Button/GamePlay.cs new file mode 100644 index 0000000..53ea174 --- /dev/null +++ b/Falling_Button/GamePlay.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Falling_Button +{ + public partial class GamePlay : Form + { + + public GamePlay() + { + InitializeComponent(); + InitGame(); + } + + private void timer_UpdateGame_Tick(object sender, EventArgs e) + { + PlayerMove(); + PlayerOver(); + LongButtonsMove(); + ScoreProcess(); + } + + private void timer_GenerateLongButton_Tick(object sender, EventArgs e) + { + SpawnLongButton(); + } + + private void button_Player_Click(object sender, EventArgs e) + { + PlayerJump(); + } + + private void GamePlay_MouseDown(object sender, MouseEventArgs e) + { + PlayerJump(); + } + + private void GamePlay_KeyDown(object sender, KeyEventArgs e) + { + PlayerJump(); + } + + //自定义函数 + int score = 0;//得分 + const double JUMP_SPEED = 3.5; + double dy = 0.0; + private void InitGame() + { + dy = -JUMP_SPEED;//负值向上 + } + + private void PlayerMove() + { + button_Player.Location = new Point(button_Player.Location.X, button_Player.Location.Y + (int)dy); + dy += 0.25; + if (button_Player.Location.Y < 0)//防止button_Player跳出窗口外 + { + button_Player.Location = new Point(button_Player.Location.X, 0); + dy = 0.0; + } + } + + private void PlayerJump() + { + dy = -JUMP_SPEED; + } + + private void PlayerOver() + { + if(button_Player.Location.Y > this.Size.Height + 64) + { + GameOverProcess(); + } + } + + //长按钮(指显卡) + List