diff --git a/ShiftOS.WinForms/Applications/Snakey.Designer.cs b/ShiftOS.WinForms/Applications/Snakey.Designer.cs index 6a39b77..6d9d43f 100644 --- a/ShiftOS.WinForms/Applications/Snakey.Designer.cs +++ b/ShiftOS.WinForms/Applications/Snakey.Designer.cs @@ -29,6 +29,8 @@ private void InitializeComponent() { this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // tableLayoutPanel1 @@ -44,7 +46,7 @@ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 26F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 26F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 26F)); - this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 31); + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 10; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F)); @@ -60,18 +62,41 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(260, 260); this.tableLayoutPanel1.TabIndex = 2; // + // button1 + // + this.button1.Location = new System.Drawing.Point(4, 270); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 3; + this.button1.Text = "Play"; + this.button1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(85, 275); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(44, 13); + this.label1.TabIndex = 4; + this.label1.Text = "Fruits: 0"; + // // Snakey // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); + this.Controls.Add(this.button1); this.Controls.Add(this.tableLayoutPanel1); this.Name = "Snakey"; - this.Size = new System.Drawing.Size(384, 389); + this.Size = new System.Drawing.Size(317, 329); this.ResumeLayout(false); + this.PerformLayout(); } #endregion private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label1; } } diff --git a/ShiftOS.WinForms/Applications/Snakey.cs b/ShiftOS.WinForms/Applications/Snakey.cs index 855e25e..b8b1ece 100644 --- a/ShiftOS.WinForms/Applications/Snakey.cs +++ b/ShiftOS.WinForms/Applications/Snakey.cs @@ -18,6 +18,7 @@ namespace ShiftOS.WinForms.Applications public partial class Snakey : UserControl, IShiftOSWindow { private int[,] snakemap; + private int snakedirection = 0; // 0 - Left, 1 - Down, 2 - Right, 3 - Up public Snakey() { @@ -29,6 +30,31 @@ namespace ShiftOS.WinForms.Applications makeGrid(); } + private void OnKeyPress(object sender, KeyPressEventArgs e) + { + switch (e.KeyChar) + { + case (char)Keys.Up: + snakedirection = 3; + break; + + case (char)Keys.Down: + snakedirection = 1; + break; + + case (char)Keys.Left: + snakedirection = 0; + break; + + case (char)Keys.Right: + snakedirection = 2; + break; + + default: + break; + } + } + private void makeGrid() { for (int x = 0; x < 10; x++)