diff --git a/App.config b/App.config
index 8e15646..8fc0551 100644
--- a/App.config
+++ b/App.config
@@ -1,6 +1,6 @@
-
+
-
+
-
\ No newline at end of file
+
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index 49cbd52..50e4916 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -1,17 +1,17 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34014
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace twozerofoureight.Properties
-{
-
-
+namespace twozerofoureight.Properties {
+ using System;
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -19,51 +19,43 @@ namespace twozerofoureight.Properties
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ 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()
- {
+ internal Resources() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("twozerofoureight.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index afe8e9d..73f387b 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -1,28 +1,24 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34014
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace twozerofoureight.Properties
-{
-
-
+namespace twozerofoureight.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
- {
-
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.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
- {
+
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
diff --git a/TwoZeroFourEightModel.cs b/TwoZeroFourEightModel.cs
index 2c70ab6..b0d74e3 100644
--- a/TwoZeroFourEightModel.cs
+++ b/TwoZeroFourEightModel.cs
@@ -11,6 +11,7 @@ class TwoZeroFourEightModel : Model
protected int boardSize; // default is 4
protected int[,] board;
protected Random rand;
+ public int score = 0;
public TwoZeroFourEightModel() : this(4)
{
@@ -39,7 +40,7 @@ public TwoZeroFourEightModel(int size)
private int[,] Random(int[,] input)
{
- while (true)
+ while (!BlockFull())
{
int x = rand.Next(boardSize);
int y = rand.Next(boardSize);
@@ -82,6 +83,7 @@ public void PerformDown()
if (j > 0 && buffer[j] != 0 && buffer[j] == buffer[j - 1])
{
buffer[j - 1] *= 2;
+ score += buffer[j - 1];
buffer[j] = 0;
}
}
@@ -134,6 +136,7 @@ public void PerformUp()
if (j > 0 && buffer[j] != 0 && buffer[j] == buffer[j - 1])
{
buffer[j - 1] *= 2;
+ score += buffer[j - 1];
buffer[j] = 0;
}
}
@@ -188,6 +191,7 @@ public void PerformRight()
if (j > 0 && buffer[j] != 0 && buffer[j] == buffer[j - 1])
{
buffer[j - 1] *= 2;
+ score += buffer[j - 1];
buffer[j] = 0;
}
}
@@ -239,6 +243,7 @@ public void PerformLeft()
if (j > 0 && buffer[j] != 0 && buffer[j] == buffer[j - 1])
{
buffer[j - 1] *= 2;
+ score += buffer[j - 1];
buffer[j] = 0;
}
}
@@ -260,5 +265,62 @@ public void PerformLeft()
board = Random(board);
NotifyAll();
}
+
+ public bool BlockFull()
+ {
+ int count = 0;
+ foreach (int block in board)
+ {
+ if (block > 0)
+ {
+ count++;
+ }
+ }
+ if (count == 16) return true;
+ else return false;
+ }
+
+ public bool GameOver()
+ {
+ int count = 0;
+ for (int x = 0; x < 3; x++)
+ {
+ for (int y = 0; y < 4; y++)
+ {
+ if (y != 3)
+ {
+ if (board[x, y] != board[x, y + 1] && board[x, y] != board[x + 1, y])
+ {
+ count++;
+ }
+ }
+ else
+ {
+ if (board[x, y] != board[x + 1, y])
+ {
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count >= 12)
+ {
+ if (BlockFull())
+ {
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public string Allscore()
+ {
+ return score.ToString();
+ }
}
}
diff --git a/TwoZeroFourEightView.Designer.cs b/TwoZeroFourEightView.Designer.cs
index 8d079e6..3b08d34 100644
--- a/TwoZeroFourEightView.Designer.cs
+++ b/TwoZeroFourEightView.Designer.cs
@@ -48,6 +48,8 @@ private void InitializeComponent()
this.btnUp = new System.Windows.Forms.Button();
this.btnRight = new System.Windows.Forms.Button();
this.btnDown = new System.Windows.Forms.Button();
+ this.ScoreBlock = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lbl00
@@ -55,9 +57,10 @@ private void InitializeComponent()
this.lbl00.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl00.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl00.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl00.Location = new System.Drawing.Point(19, 11);
+ this.lbl00.Location = new System.Drawing.Point(25, 18);
+ this.lbl00.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl00.Name = "lbl00";
- this.lbl00.Size = new System.Drawing.Size(51, 51);
+ this.lbl00.Size = new System.Drawing.Size(93, 78);
this.lbl00.TabIndex = 0;
this.lbl00.Text = "0";
//
@@ -66,9 +69,10 @@ private void InitializeComponent()
this.lbl01.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl01.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl01.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl01.Location = new System.Drawing.Point(76, 9);
+ this.lbl01.Location = new System.Drawing.Point(117, 18);
+ this.lbl01.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl01.Name = "lbl01";
- this.lbl01.Size = new System.Drawing.Size(51, 51);
+ this.lbl01.Size = new System.Drawing.Size(97, 78);
this.lbl01.TabIndex = 1;
this.lbl01.Text = "0";
//
@@ -77,9 +81,10 @@ private void InitializeComponent()
this.lbl02.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl02.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl02.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl02.Location = new System.Drawing.Point(140, 11);
+ this.lbl02.Location = new System.Drawing.Point(213, 18);
+ this.lbl02.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl02.Name = "lbl02";
- this.lbl02.Size = new System.Drawing.Size(51, 51);
+ this.lbl02.Size = new System.Drawing.Size(99, 78);
this.lbl02.TabIndex = 2;
this.lbl02.Text = "0";
//
@@ -88,9 +93,10 @@ private void InitializeComponent()
this.lbl03.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl03.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl03.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl03.Location = new System.Drawing.Point(209, 9);
+ this.lbl03.Location = new System.Drawing.Point(310, 18);
+ this.lbl03.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl03.Name = "lbl03";
- this.lbl03.Size = new System.Drawing.Size(51, 51);
+ this.lbl03.Size = new System.Drawing.Size(106, 78);
this.lbl03.TabIndex = 3;
this.lbl03.Text = "0";
//
@@ -99,9 +105,10 @@ private void InitializeComponent()
this.lbl13.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl13.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl13.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl13.Location = new System.Drawing.Point(209, 74);
+ this.lbl13.Location = new System.Drawing.Point(310, 96);
+ this.lbl13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl13.Name = "lbl13";
- this.lbl13.Size = new System.Drawing.Size(51, 51);
+ this.lbl13.Size = new System.Drawing.Size(106, 78);
this.lbl13.TabIndex = 7;
this.lbl13.Text = "0";
//
@@ -110,9 +117,10 @@ private void InitializeComponent()
this.lbl12.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl12.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl12.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl12.Location = new System.Drawing.Point(142, 74);
+ this.lbl12.Location = new System.Drawing.Point(213, 96);
+ this.lbl12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl12.Name = "lbl12";
- this.lbl12.Size = new System.Drawing.Size(51, 51);
+ this.lbl12.Size = new System.Drawing.Size(99, 78);
this.lbl12.TabIndex = 6;
this.lbl12.Text = "0";
//
@@ -121,9 +129,10 @@ private void InitializeComponent()
this.lbl11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl11.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl11.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl11.Location = new System.Drawing.Point(76, 74);
+ this.lbl11.Location = new System.Drawing.Point(117, 96);
+ this.lbl11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl11.Name = "lbl11";
- this.lbl11.Size = new System.Drawing.Size(51, 51);
+ this.lbl11.Size = new System.Drawing.Size(97, 78);
this.lbl11.TabIndex = 5;
this.lbl11.Text = "0";
//
@@ -132,9 +141,10 @@ private void InitializeComponent()
this.lbl10.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl10.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl10.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl10.Location = new System.Drawing.Point(19, 74);
+ this.lbl10.Location = new System.Drawing.Point(25, 96);
+ this.lbl10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl10.Name = "lbl10";
- this.lbl10.Size = new System.Drawing.Size(51, 51);
+ this.lbl10.Size = new System.Drawing.Size(93, 78);
this.lbl10.TabIndex = 4;
this.lbl10.Text = "0";
//
@@ -143,9 +153,10 @@ private void InitializeComponent()
this.lbl23.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl23.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl23.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl23.Location = new System.Drawing.Point(209, 138);
+ this.lbl23.Location = new System.Drawing.Point(310, 174);
+ this.lbl23.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl23.Name = "lbl23";
- this.lbl23.Size = new System.Drawing.Size(51, 51);
+ this.lbl23.Size = new System.Drawing.Size(106, 75);
this.lbl23.TabIndex = 11;
this.lbl23.Text = "0";
//
@@ -154,9 +165,10 @@ private void InitializeComponent()
this.lbl22.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl22.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl22.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl22.Location = new System.Drawing.Point(142, 138);
+ this.lbl22.Location = new System.Drawing.Point(213, 174);
+ this.lbl22.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl22.Name = "lbl22";
- this.lbl22.Size = new System.Drawing.Size(51, 51);
+ this.lbl22.Size = new System.Drawing.Size(99, 75);
this.lbl22.TabIndex = 10;
this.lbl22.Text = "0";
//
@@ -165,9 +177,10 @@ private void InitializeComponent()
this.lbl21.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl21.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl21.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl21.Location = new System.Drawing.Point(82, 138);
+ this.lbl21.Location = new System.Drawing.Point(117, 174);
+ this.lbl21.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl21.Name = "lbl21";
- this.lbl21.Size = new System.Drawing.Size(51, 51);
+ this.lbl21.Size = new System.Drawing.Size(97, 75);
this.lbl21.TabIndex = 9;
this.lbl21.Text = "0";
//
@@ -176,9 +189,10 @@ private void InitializeComponent()
this.lbl20.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl20.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl20.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl20.Location = new System.Drawing.Point(19, 138);
+ this.lbl20.Location = new System.Drawing.Point(25, 174);
+ this.lbl20.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl20.Name = "lbl20";
- this.lbl20.Size = new System.Drawing.Size(51, 51);
+ this.lbl20.Size = new System.Drawing.Size(93, 75);
this.lbl20.TabIndex = 8;
this.lbl20.Text = "0";
//
@@ -187,9 +201,10 @@ private void InitializeComponent()
this.lbl33.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl33.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl33.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl33.Location = new System.Drawing.Point(209, 201);
+ this.lbl33.Location = new System.Drawing.Point(310, 249);
+ this.lbl33.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl33.Name = "lbl33";
- this.lbl33.Size = new System.Drawing.Size(51, 51);
+ this.lbl33.Size = new System.Drawing.Size(106, 76);
this.lbl33.TabIndex = 15;
this.lbl33.Text = "0";
//
@@ -198,9 +213,10 @@ private void InitializeComponent()
this.lbl32.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl32.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl32.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl32.Location = new System.Drawing.Point(142, 201);
+ this.lbl32.Location = new System.Drawing.Point(213, 249);
+ this.lbl32.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl32.Name = "lbl32";
- this.lbl32.Size = new System.Drawing.Size(51, 51);
+ this.lbl32.Size = new System.Drawing.Size(99, 76);
this.lbl32.TabIndex = 14;
this.lbl32.Text = "0";
//
@@ -209,9 +225,10 @@ private void InitializeComponent()
this.lbl31.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl31.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl31.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl31.Location = new System.Drawing.Point(82, 201);
+ this.lbl31.Location = new System.Drawing.Point(117, 249);
+ this.lbl31.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl31.Name = "lbl31";
- this.lbl31.Size = new System.Drawing.Size(51, 51);
+ this.lbl31.Size = new System.Drawing.Size(97, 76);
this.lbl31.TabIndex = 13;
this.lbl31.Text = "0";
//
@@ -220,57 +237,93 @@ private void InitializeComponent()
this.lbl30.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl30.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl30.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.lbl30.Location = new System.Drawing.Point(19, 201);
+ this.lbl30.Location = new System.Drawing.Point(25, 249);
+ this.lbl30.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbl30.Name = "lbl30";
- this.lbl30.Size = new System.Drawing.Size(51, 51);
+ this.lbl30.Size = new System.Drawing.Size(93, 76);
this.lbl30.TabIndex = 12;
this.lbl30.Text = "0";
//
// btnLeft
//
- this.btnLeft.Location = new System.Drawing.Point(85, 336);
+ this.btnLeft.Font = new System.Drawing.Font("Orator Std", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.btnLeft.Location = new System.Drawing.Point(97, 430);
+ this.btnLeft.Margin = new System.Windows.Forms.Padding(4);
this.btnLeft.Name = "btnLeft";
- this.btnLeft.Size = new System.Drawing.Size(53, 45);
+ this.btnLeft.Size = new System.Drawing.Size(71, 55);
this.btnLeft.TabIndex = 16;
- this.btnLeft.Text = "<";
+ this.btnLeft.Text = "←";
this.btnLeft.UseVisualStyleBackColor = true;
this.btnLeft.Click += new System.EventHandler(this.btnLeft_Click);
+ this.btnLeft.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.btnX_PreviewKeyDown);
//
// btnUp
//
- this.btnUp.Location = new System.Drawing.Point(140, 307);
+ this.btnUp.Font = new System.Drawing.Font("Orator Std", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.btnUp.Location = new System.Drawing.Point(176, 400);
+ this.btnUp.Margin = new System.Windows.Forms.Padding(4);
this.btnUp.Name = "btnUp";
- this.btnUp.Size = new System.Drawing.Size(53, 45);
+ this.btnUp.Size = new System.Drawing.Size(71, 55);
this.btnUp.TabIndex = 17;
- this.btnUp.Text = "^";
+ this.btnUp.Text = "↑";
this.btnUp.UseVisualStyleBackColor = true;
this.btnUp.Click += new System.EventHandler(this.btnUp_Click);
+ this.btnUp.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.btnX_PreviewKeyDown);
//
// btnRight
//
- this.btnRight.Location = new System.Drawing.Point(195, 336);
+ this.btnRight.Font = new System.Drawing.Font("Orator Std", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.btnRight.Location = new System.Drawing.Point(255, 430);
+ this.btnRight.Margin = new System.Windows.Forms.Padding(4);
this.btnRight.Name = "btnRight";
- this.btnRight.Size = new System.Drawing.Size(53, 45);
+ this.btnRight.Size = new System.Drawing.Size(71, 55);
this.btnRight.TabIndex = 18;
- this.btnRight.Text = ">";
+ this.btnRight.Text = "→";
this.btnRight.UseVisualStyleBackColor = true;
this.btnRight.Click += new System.EventHandler(this.btnRight_Click);
+ this.btnRight.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.btnX_PreviewKeyDown);
//
// btnDown
//
- this.btnDown.Location = new System.Drawing.Point(140, 371);
+ this.btnDown.Font = new System.Drawing.Font("Orator Std", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.btnDown.Location = new System.Drawing.Point(176, 463);
+ this.btnDown.Margin = new System.Windows.Forms.Padding(4);
this.btnDown.Name = "btnDown";
- this.btnDown.Size = new System.Drawing.Size(53, 45);
+ this.btnDown.Size = new System.Drawing.Size(71, 57);
this.btnDown.TabIndex = 19;
- this.btnDown.Text = "v";
+ this.btnDown.Text = "↓";
this.btnDown.UseVisualStyleBackColor = true;
this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
+ this.btnDown.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.btnX_PreviewKeyDown);
//
- // Form1
+ // ScoreBlock
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.ScoreBlock.Font = new System.Drawing.Font("Letter Gothic Std", 13.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.ScoreBlock.Location = new System.Drawing.Point(157, 342);
+ this.ScoreBlock.Multiline = true;
+ this.ScoreBlock.Name = "ScoreBlock";
+ this.ScoreBlock.ReadOnly = true;
+ this.ScoreBlock.Size = new System.Drawing.Size(191, 40);
+ this.ScoreBlock.TabIndex = 20;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Stencil", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(65, 345);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(86, 29);
+ this.label1.TabIndex = 21;
+ this.label1.Text = "SCORE";
+ //
+ // TwoZeroFourEightView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(344, 428);
+ this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
+ this.ClientSize = new System.Drawing.Size(445, 533);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.ScoreBlock);
this.Controls.Add(this.btnDown);
this.Controls.Add(this.btnRight);
this.Controls.Add(this.btnUp);
@@ -291,9 +344,11 @@ private void InitializeComponent()
this.Controls.Add(this.lbl02);
this.Controls.Add(this.lbl01);
this.Controls.Add(this.lbl00);
- this.Name = "Form1";
+ this.Margin = new System.Windows.Forms.Padding(4);
+ this.Name = "TwoZeroFourEightView";
this.Text = "Form1";
this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -319,6 +374,8 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnUp;
private System.Windows.Forms.Button btnRight;
private System.Windows.Forms.Button btnDown;
+ private System.Windows.Forms.TextBox ScoreBlock;
+ private System.Windows.Forms.Label label1;
}
}
diff --git a/TwoZeroFourEightView.cs b/TwoZeroFourEightView.cs
index 8201edf..a0599db 100644
--- a/TwoZeroFourEightView.cs
+++ b/TwoZeroFourEightView.cs
@@ -25,9 +25,20 @@ public TwoZeroFourEightView()
controller.ActionPerformed(TwoZeroFourEightController.LEFT);
}
+ private void EndGame()
+ {
+ MessageBox.Show("GAME OVER!!\nPlay again!!!!");
+ }
+
public void Notify(Model m)
{
UpdateBoard(((TwoZeroFourEightModel) m).GetBoard());
+ ScoreBlock.Text = ((TwoZeroFourEightModel)model).Allscore();
+ if (((TwoZeroFourEightModel)model).GameOver())
+ {
+ EndGame();
+ }
+
}
private void UpdateTile(Label l, int i)
@@ -41,17 +52,43 @@ private void UpdateTile(Label l, int i)
switch (i)
{
case 0:
- l.BackColor = Color.Gray;
+ l.BackColor = Color.Thistle;
break;
case 2:
- l.BackColor = Color.DarkGray;
+ l.BackColor = Color.MediumVioletRed;
break;
case 4:
- l.BackColor = Color.Orange;
+ l.BackColor = Color.MediumOrchid;
break;
case 8:
- l.BackColor = Color.Red;
+ l.BackColor = Color.MediumPurple;
+ break;
+ case 16:
+ l.BackColor = Color.CornflowerBlue;
+ break;
+ case 32:
+ l.BackColor = Color.SkyBlue;
+ break;
+ case 64:
+ l.BackColor = Color.Turquoise;
+ break;
+ case 128:
+ l.BackColor = Color.MediumAquamarine;
+ break;
+ case 256:
+ l.BackColor = Color.BurlyWood;
+ break;
+ case 512:
+ l.BackColor = Color.LightSalmon;
+ break;
+ case 1024:
+ l.BackColor = Color.LightCoral;
break;
+ case 2048:
+ l.BackColor = Color.IndianRed;
+ break;
+
+
default:
l.BackColor = Color.Green;
break;
@@ -97,5 +134,32 @@ private void btnDown_Click(object sender, EventArgs e)
controller.ActionPerformed(TwoZeroFourEightController.DOWN);
}
+
+ private void btnX_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+ {
+ e.IsInputKey = true;
+ switch (e.KeyCode)
+ {
+ case Keys.Up:
+ btnUp.Focus();
+ controller.ActionPerformed(TwoZeroFourEightController.UP);
+ break;
+ case Keys.Down:
+ btnDown.Focus();
+ controller.ActionPerformed(TwoZeroFourEightController.DOWN);
+ break;
+ case Keys.Left:
+ btnLeft.Focus();
+ controller.ActionPerformed(TwoZeroFourEightController.LEFT);
+ break;
+ case Keys.Right:
+ btnRight.Focus();
+ controller.ActionPerformed(TwoZeroFourEightController.RIGHT);
+ break;
+ }
+
+ }
+
+
}
}
diff --git a/twozerofoureight.csproj b/twozerofoureight.csproj
index e23ffd7..5c2e557 100644
--- a/twozerofoureight.csproj
+++ b/twozerofoureight.csproj
@@ -9,8 +9,9 @@
Properties
twozerofoureight
twozerofoureight
- v4.5
+ v4.7.1
512
+
AnyCPU
@@ -68,6 +69,7 @@
True
Resources.resx
+ True
SettingsSingleFileGenerator