miércoles, 3 de febrero de 2016

juego de cartas, Card Game en c#, juego de pares




Elementos que vamos a necesitar;
 

 


Código del programa;

       public class Form1 : System.Windows.Forms.Form
       {
             public int[,] arr=new int[4,5];
             public int[] a=new int[17];
             private PictureBox img1;
             private PictureBox img2;
             private int i=0;
             private int j=0;
             private int C1=0;
             private int C2=0;
             private int gc=0;
             private int Player=1;
             bool temp=false;
             private System.Windows.Forms.Panel panel1;
             private System.Windows.Forms.PictureBox pictureBox1;
             private System.Windows.Forms.PictureBox pictureBox2;
             private System.Windows.Forms.PictureBox pictureBox3;
             private System.Windows.Forms.PictureBox pictureBox4;
             private System.Windows.Forms.PictureBox pictureBox5;
             private System.Windows.Forms.PictureBox pictureBox6;
             private System.Windows.Forms.PictureBox pictureBox7;
             private System.Windows.Forms.PictureBox pictureBox8;
             private System.Windows.Forms.PictureBox pictureBox9;
             private System.Windows.Forms.PictureBox pictureBox10;
             private System.Windows.Forms.PictureBox pictureBox11;
             private System.Windows.Forms.PictureBox pictureBox12;
             private System.Windows.Forms.PictureBox pictureBox13;
             private System.Windows.Forms.PictureBox pictureBox14;
             private System.Windows.Forms.PictureBox pictureBox15;
             private System.Windows.Forms.PictureBox pictureBox16;
             private System.Windows.Forms.PictureBox pictureBox17;
             private System.Windows.Forms.PictureBox pictureBox18;
             private System.Windows.Forms.PictureBox pictureBox19;
             private System.Windows.Forms.PictureBox pictureBox20;
             private System.Windows.Forms.Button button1;
             private System.Windows.Forms.Label label1;
             private System.Windows.Forms.Label label2;
             private System.Windows.Forms.Label l2;
             private System.Windows.Forms.Label l1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Timer timer1;
             private System.ComponentModel.IContainer components;

             public Form1()
             {
                    InitializeComponent();
             }
             protected override void Dispose( bool disposing )
             {
                    if( disposing )
                    {
                           if (components != null)
                           {
                                  components.Dispose();
                           }
                    }
                    base.Dispose( disposing );
             }
             #region Windows Form Designer generated code
             private void InitializeComponent()
             {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.panel1 = new System.Windows.Forms.Panel();
            this.button2 = new System.Windows.Forms.Button();
            this.l2 = new System.Windows.Forms.Label();
            this.l1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.pictureBox2 = new System.Windows.Forms.PictureBox();
            this.pictureBox3 = new System.Windows.Forms.PictureBox();
            this.pictureBox4 = new System.Windows.Forms.PictureBox();
            this.pictureBox5 = new System.Windows.Forms.PictureBox();
            this.pictureBox6 = new System.Windows.Forms.PictureBox();
            this.pictureBox7 = new System.Windows.Forms.PictureBox();
            this.pictureBox8 = new System.Windows.Forms.PictureBox();
            this.pictureBox9 = new System.Windows.Forms.PictureBox();
            this.pictureBox10 = new System.Windows.Forms.PictureBox();
            this.pictureBox11 = new System.Windows.Forms.PictureBox();
            this.pictureBox12 = new System.Windows.Forms.PictureBox();
            this.pictureBox13 = new System.Windows.Forms.PictureBox();
            this.pictureBox14 = new System.Windows.Forms.PictureBox();
            this.pictureBox15 = new System.Windows.Forms.PictureBox();
            this.pictureBox16 = new System.Windows.Forms.PictureBox();
            this.pictureBox17 = new System.Windows.Forms.PictureBox();
            this.pictureBox18 = new System.Windows.Forms.PictureBox();
            this.pictureBox19 = new System.Windows.Forms.PictureBox();
            this.pictureBox20 = new System.Windows.Forms.PictureBox();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox9)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox10)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox11)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox12)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox13)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox14)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox15)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox16)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox17)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox18)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox19)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox20)).BeginInit();
            this.SuspendLayout();
            //
            // panel1
            //
            this.panel1.BackColor = System.Drawing.Color.Ivory;
            this.panel1.Controls.Add(this.button2);
            this.panel1.Controls.Add(this.l2);
            this.panel1.Controls.Add(this.l1);
            this.panel1.Controls.Add(this.label2);
            this.panel1.Controls.Add(this.label1);
            this.panel1.Controls.Add(this.button1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel1.Location = new System.Drawing.Point(0, 494);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(482, 32);
            this.panel1.TabIndex = 20;
            //
            // button2
            //
            this.button2.BackColor = System.Drawing.Color.SteelBlue;
            this.button2.Location = new System.Drawing.Point(936, 5);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(64, 24);
            this.button2.TabIndex = 5;
            this.button2.Text = "Exit";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // l2
            //
            this.l2.AutoSize = true;
            this.l2.BackColor = System.Drawing.Color.LightYellow;
            this.l2.Location = new System.Drawing.Point(413, 8);
            this.l2.Name = "l2";
            this.l2.Size = new System.Drawing.Size(13, 13);
            this.l2.TabIndex = 4;
            this.l2.Text = "0";
            //
            // l1
            //
            this.l1.AutoSize = true;
            this.l1.BackColor = System.Drawing.Color.LightYellow;
            this.l1.Location = new System.Drawing.Point(232, 10);
            this.l1.Name = "l1";
            this.l1.Size = new System.Drawing.Size(13, 13);
            this.l1.TabIndex = 3;
            this.l1.Text = "0";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.BackColor = System.Drawing.Color.LightYellow;
            this.label2.Location = new System.Drawing.Point(349, 8);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(48, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Player 2:";
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.BackColor = System.Drawing.Color.LightYellow;
            this.label1.Location = new System.Drawing.Point(168, 10);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(48, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Player 1:";
            //
            // button1
            //
            this.button1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.button1.Location = new System.Drawing.Point(15, 4);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(64, 24);
            this.button1.TabIndex = 0;
            this.button1.Text = "New";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // pictureBox1
            //
            this.pictureBox1.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
            this.pictureBox1.Location = new System.Drawing.Point(12, 46);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(72, 96);
            this.pictureBox1.TabIndex = 21;
            this.pictureBox1.TabStop = false;
            this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
            //
            // pictureBox2
            //
            this.pictureBox2.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
            this.pictureBox2.Location = new System.Drawing.Point(108, 46);
            this.pictureBox2.Name = "pictureBox2";
            this.pictureBox2.Size = new System.Drawing.Size(72, 96);
            this.pictureBox2.TabIndex = 22;
            this.pictureBox2.TabStop = false;
            this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
            //
            // pictureBox3
            //
            this.pictureBox3.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
            this.pictureBox3.Location = new System.Drawing.Point(204, 46);
            this.pictureBox3.Name = "pictureBox3";
            this.pictureBox3.Size = new System.Drawing.Size(72, 96);
            this.pictureBox3.TabIndex = 23;
            this.pictureBox3.TabStop = false;
            this.pictureBox3.Click += new System.EventHandler(this.pictureBox3_Click);
            //
            // pictureBox4
            //
            this.pictureBox4.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
            this.pictureBox4.Location = new System.Drawing.Point(300, 46);
            this.pictureBox4.Name = "pictureBox4";
            this.pictureBox4.Size = new System.Drawing.Size(72, 96);
            this.pictureBox4.TabIndex = 24;
            this.pictureBox4.TabStop = false;
            this.pictureBox4.Click += new System.EventHandler(this.pictureBox4_Click);
            //
            // pictureBox5
            //
            this.pictureBox5.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
            this.pictureBox5.Location = new System.Drawing.Point(396, 46);
            this.pictureBox5.Name = "pictureBox5";
            this.pictureBox5.Size = new System.Drawing.Size(72, 96);
            this.pictureBox5.TabIndex = 25;
            this.pictureBox5.TabStop = false;
            this.pictureBox5.Click += new System.EventHandler(this.pictureBox5_Click);
            //
            // pictureBox6
            //
            this.pictureBox6.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
            this.pictureBox6.Location = new System.Drawing.Point(12, 158);
            this.pictureBox6.Name = "pictureBox6";
            this.pictureBox6.Size = new System.Drawing.Size(72, 96);
            this.pictureBox6.TabIndex = 26;
            this.pictureBox6.TabStop = false;
            this.pictureBox6.Click += new System.EventHandler(this.pictureBox6_Click);
            //
            // pictureBox7
            //
            this.pictureBox7.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox7.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox7.Image")));
            this.pictureBox7.Location = new System.Drawing.Point(108, 158);
            this.pictureBox7.Name = "pictureBox7";
            this.pictureBox7.Size = new System.Drawing.Size(72, 96);
            this.pictureBox7.TabIndex = 27;
            this.pictureBox7.TabStop = false;
            this.pictureBox7.Click += new System.EventHandler(this.pictureBox7_Click);
            //
            // pictureBox8
            //
            this.pictureBox8.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox8.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox8.Image")));
            this.pictureBox8.Location = new System.Drawing.Point(204, 158);
            this.pictureBox8.Name = "pictureBox8";
            this.pictureBox8.Size = new System.Drawing.Size(72, 96);
            this.pictureBox8.TabIndex = 28;
            this.pictureBox8.TabStop = false;
            this.pictureBox8.Click += new System.EventHandler(this.pictureBox8_Click);
            //
            // pictureBox9
            //
            this.pictureBox9.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox9.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox9.Image")));
            this.pictureBox9.Location = new System.Drawing.Point(300, 158);
            this.pictureBox9.Name = "pictureBox9";
            this.pictureBox9.Size = new System.Drawing.Size(72, 96);
            this.pictureBox9.TabIndex = 29;
            this.pictureBox9.TabStop = false;
            this.pictureBox9.Click += new System.EventHandler(this.pictureBox9_Click);
            //
            // pictureBox10
            //
            this.pictureBox10.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox10.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox10.Image")));
            this.pictureBox10.Location = new System.Drawing.Point(396, 158);
            this.pictureBox10.Name = "pictureBox10";
            this.pictureBox10.Size = new System.Drawing.Size(72, 96);
            this.pictureBox10.TabIndex = 30;
            this.pictureBox10.TabStop = false;
            this.pictureBox10.Click += new System.EventHandler(this.pictureBox10_Click);
            //
            // pictureBox11
            //
            this.pictureBox11.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox11.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox11.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox11.Image")));
            this.pictureBox11.Location = new System.Drawing.Point(12, 270);
            this.pictureBox11.Name = "pictureBox11";
            this.pictureBox11.Size = new System.Drawing.Size(72, 96);
            this.pictureBox11.TabIndex = 31;
            this.pictureBox11.TabStop = false;
            this.pictureBox11.Click += new System.EventHandler(this.pictureBox11_Click);
            //
            // pictureBox12
            //
            this.pictureBox12.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox12.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox12.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox12.Image")));
            this.pictureBox12.Location = new System.Drawing.Point(108, 270);
            this.pictureBox12.Name = "pictureBox12";
            this.pictureBox12.Size = new System.Drawing.Size(72, 96);
            this.pictureBox12.TabIndex = 32;
            this.pictureBox12.TabStop = false;
            this.pictureBox12.Click += new System.EventHandler(this.pictureBox12_Click);
            //
            // pictureBox13
            //
            this.pictureBox13.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox13.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox13.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox13.Image")));
            this.pictureBox13.Location = new System.Drawing.Point(204, 270);
            this.pictureBox13.Name = "pictureBox13";
            this.pictureBox13.Size = new System.Drawing.Size(72, 96);
            this.pictureBox13.TabIndex = 33;
            this.pictureBox13.TabStop = false;
            this.pictureBox13.Click += new System.EventHandler(this.pictureBox13_Click);
            //
            // pictureBox14
            //
            this.pictureBox14.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox14.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox14.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox14.Image")));
            this.pictureBox14.Location = new System.Drawing.Point(300, 270);
            this.pictureBox14.Name = "pictureBox14";
            this.pictureBox14.Size = new System.Drawing.Size(72, 96);
            this.pictureBox14.TabIndex = 34;
            this.pictureBox14.TabStop = false;
            this.pictureBox14.Click += new System.EventHandler(this.pictureBox14_Click);
            //
            // pictureBox15
            //
            this.pictureBox15.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox15.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox15.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox15.Image")));
            this.pictureBox15.Location = new System.Drawing.Point(396, 270);
            this.pictureBox15.Name = "pictureBox15";
            this.pictureBox15.Size = new System.Drawing.Size(72, 96);
            this.pictureBox15.TabIndex = 35;
            this.pictureBox15.TabStop = false;
            this.pictureBox15.Click += new System.EventHandler(this.pictureBox15_Click);
            //
            // pictureBox16
            //
            this.pictureBox16.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox16.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox16.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox16.Image")));
            this.pictureBox16.Location = new System.Drawing.Point(12, 382);
            this.pictureBox16.Name = "pictureBox16";
            this.pictureBox16.Size = new System.Drawing.Size(72, 96);
            this.pictureBox16.TabIndex = 36;
            this.pictureBox16.TabStop = false;
            this.pictureBox16.Click += new System.EventHandler(this.pictureBox16_Click);
            //
            // pictureBox17
            //
            this.pictureBox17.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox17.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox17.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox17.Image")));
            this.pictureBox17.Location = new System.Drawing.Point(108, 382);
            this.pictureBox17.Name = "pictureBox17";
            this.pictureBox17.Size = new System.Drawing.Size(72, 96);
            this.pictureBox17.TabIndex = 37;
            this.pictureBox17.TabStop = false;
            this.pictureBox17.Click += new System.EventHandler(this.pictureBox17_Click);
            //
            // pictureBox18
            //
            this.pictureBox18.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox18.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox18.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox18.Image")));
            this.pictureBox18.Location = new System.Drawing.Point(204, 382);
            this.pictureBox18.Name = "pictureBox18";
            this.pictureBox18.Size = new System.Drawing.Size(72, 96);
            this.pictureBox18.TabIndex = 38;
            this.pictureBox18.TabStop = false;
            this.pictureBox18.Click += new System.EventHandler(this.pictureBox18_Click);
            //
            // pictureBox19
            //
            this.pictureBox19.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox19.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox19.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox19.Image")));
            this.pictureBox19.Location = new System.Drawing.Point(300, 382);
            this.pictureBox19.Name = "pictureBox19";
            this.pictureBox19.Size = new System.Drawing.Size(72, 96);
            this.pictureBox19.TabIndex = 39;
            this.pictureBox19.TabStop = false;
            this.pictureBox19.Click += new System.EventHandler(this.pictureBox19_Click);
            //
            // pictureBox20
            //
            this.pictureBox20.BackColor = System.Drawing.Color.DarkGreen;
            this.pictureBox20.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.pictureBox20.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox20.Image")));
            this.pictureBox20.Location = new System.Drawing.Point(396, 382);
            this.pictureBox20.Name = "pictureBox20";
            this.pictureBox20.Size = new System.Drawing.Size(72, 96);
            this.pictureBox20.TabIndex = 40;
            this.pictureBox20.TabStop = false;
            this.pictureBox20.Click += new System.EventHandler(this.pictureBox20_Click);
            //
            // timer1
            //
            this.timer1.Interval = 150;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.BackColor = System.Drawing.Color.AliceBlue;
            this.ClientSize = new System.Drawing.Size(482, 526);
            this.Controls.Add(this.pictureBox20);
            this.Controls.Add(this.pictureBox19);
            this.Controls.Add(this.pictureBox18);
            this.Controls.Add(this.pictureBox17);
            this.Controls.Add(this.pictureBox16);
            this.Controls.Add(this.pictureBox15);
            this.Controls.Add(this.pictureBox14);
            this.Controls.Add(this.pictureBox13);
            this.Controls.Add(this.pictureBox12);
            this.Controls.Add(this.pictureBox11);
            this.Controls.Add(this.pictureBox10);
            this.Controls.Add(this.pictureBox9);
            this.Controls.Add(this.pictureBox8);
            this.Controls.Add(this.pictureBox7);
            this.Controls.Add(this.pictureBox6);
            this.Controls.Add(this.pictureBox5);
            this.Controls.Add(this.pictureBox4);
            this.Controls.Add(this.pictureBox3);
            this.Controls.Add(this.pictureBox2);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.panel1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = " Game";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox9)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox10)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox11)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox12)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox13)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox14)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox15)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox16)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox17)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox18)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox19)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox20)).EndInit();
            this.ResumeLayout(false);

             }
             #endregion
            
             [STAThread]
      
             static void Main()
             {
                    Application.Run(new Form1());
             }
             public void Form1_ran()
             {
                    Random r1=new Random();
                    int count=0;
                    bool flag=true;
                    int b=0;
                           while(count<10)
                           {
                                  flag=true;
                                  while(flag==true)
                                  {
                                        b=r1.Next(1,17);
                                        if(a[b]==0)
                                        {
                                               a[b]=1;
                                               ++count;
                                               flag=false;
                                        }
                                  }
                                  flag=true;
                                  while(flag==true)
                                  {
                                        int i=r1.Next(0,4);
                                        int j=r1.Next(0,5);
                                        if(arr[i,j]==0)
                                        {
                                               arr[i,j]=b;
                                               flag=false;
                                        }
                                  }
                                  flag=true;
                                  while(flag==true)
                                  {
                                        int i=r1.Next(0,4);
                                        int j=r1.Next(0,5);
                                        if(arr[i,j]==0)
                                        {
                                               arr[i,j]=b;
                                               flag=false;
                                        }
                                  }

                           }
             }
             public void dis(int i,int j,object sender)
             {
                    PictureBox x=(PictureBox)sender;
                    string str="image/"+arr[i,j]+".jpg";
                    x.Image=new Bitmap(str);
                    gc++;
                    if (gc % 2 == 0)
                    {
                           img2 = (PictureBox)sender;
                           temp=true;
                           gc = 0;
                           C2 = arr[i, j];
                           if (C1 == C2 && img1!=img2)
                           {
                                  if (Player == 1)
                                  {
                                        int score = Int32.Parse(l1.Text);
                                        score += 10;
                                        l1.Text = "" + score;
                                        gc = 0;
                                  }
                                  else
                                  {
                                        int score = Int32.Parse(l2.Text);
                                        score += 10;
                                        l2.Text = "" + score;
                                        gc = 0;
                                  }
                                  img1.Visible = false;
                                  img2.Visible = false;
                           }
                           else
                           {
                                  if (img1 == img2)
                                  {
                                        gc--;
                                  }
                                  else
                                  {
                                        timer1.Enabled = true;
                                        if (Player == 1)
                                               Player = 2;
                                        else
                                               Player = 1;
                                        setPlayer();
                                  }
                           }
                    }
                    else
                    {
                           this.i = i;
                           this.j = j;
                           C1 = arr[i,j];
                           img1=(PictureBox)sender;         
                    }
             }
             private void setPlayer()
             {
                    if (Player==1)
                    {
                           label1.ForeColor=Color.Green;          
                           label2.ForeColor=Color.Red;
                    }
                    else
                    {
                           label2.ForeColor = Color.Green;
                           label1.ForeColor = Color.Red;
                    }                  
             }
             private void button2_Click(object sender, System.EventArgs e)
             {
                    Application.Exit();
             }
             private void Form1_Load(object sender, System.EventArgs e)
             {
                    this.Form1_ran();
             }
             private void button1_Click(object sender, System.EventArgs e)
             {
                    l1.Text="0";
                    l2.Text="0";
                    //PictureBox n=(PictureBox)sender;
                    string stn="image/bg.jpg";
                    pictureBox1.Image=new Bitmap(stn);
                    pictureBox1.Visible=true;
                    pictureBox2.Image=new Bitmap(stn);
                    pictureBox2.Visible=true;
                    pictureBox3.Image=new Bitmap(stn);
                    pictureBox3.Visible=true;
                    pictureBox4.Image=new Bitmap(stn);
                    pictureBox4.Visible=true;
                    pictureBox5.Image=new Bitmap(stn);
                    pictureBox5.Visible=true;
                    pictureBox6.Image=new Bitmap(stn);
                    pictureBox6.Visible=true;
                    pictureBox7.Image=new Bitmap(stn);
                    pictureBox7.Visible=true;
                    pictureBox8.Image=new Bitmap(stn);
                    pictureBox8.Visible=true;
                    pictureBox9.Image=new Bitmap(stn);
                    pictureBox9.Visible=true;
                    pictureBox10.Image=new Bitmap(stn);
                    pictureBox10.Visible=true;
                    pictureBox11.Image=new Bitmap(stn);
                    pictureBox11.Visible=true;
                    pictureBox12.Image=new Bitmap(stn);
                    pictureBox12.Visible=true;
                    pictureBox13.Image=new Bitmap(stn);
                    pictureBox13.Visible=true;
                    pictureBox14.Image=new Bitmap(stn);
                    pictureBox14.Visible=true;
                    pictureBox15.Image=new Bitmap(stn);
                    pictureBox15.Visible=true;
                    pictureBox16.Image=new Bitmap(stn);
                    pictureBox16.Visible=true;
                    pictureBox17.Image=new Bitmap(stn);
                    pictureBox17.Visible=true;
                    pictureBox18.Image=new Bitmap(stn);
                    pictureBox18.Visible=true;
                    pictureBox19.Image=new Bitmap(stn);
                    pictureBox19.Visible=true;
                    pictureBox20.Image=new Bitmap(stn);
                    pictureBox20.Visible=true;
             }
             private void pictureBox1_Click(object sender, System.EventArgs e)
             {
                    dis(0,0,pictureBox1);
             }
             private void pictureBox2_Click(object sender, System.EventArgs e)
             {
                    dis(0,1,pictureBox2);
             }
             private void pictureBox3_Click(object sender, System.EventArgs e)
             {
                    dis(0,2,pictureBox3);
             }
             private void pictureBox4_Click(object sender, System.EventArgs e)
             {
                    dis(0,3,pictureBox4);
             }
             private void pictureBox5_Click(object sender, System.EventArgs e)
             {
                    dis(0,4,pictureBox5);
             }
             private void pictureBox6_Click(object sender, System.EventArgs e)
             {
                    dis(1,0,pictureBox6);
             }
             private void pictureBox7_Click(object sender, System.EventArgs e)
             {
                    dis(1,1,pictureBox7);
             }
             private void pictureBox8_Click(object sender, System.EventArgs e)
             {
                    dis(1,2,pictureBox8);
             }
             private void pictureBox9_Click(object sender, System.EventArgs e)
             {
                    dis(1,3,pictureBox9);
             }
             private void pictureBox10_Click(object sender, System.EventArgs e)
             {
                    dis(1,4,pictureBox10);
             }
             private void pictureBox11_Click(object sender, System.EventArgs e)
             {
                    dis(2,0,pictureBox11);
             }
             private void pictureBox12_Click(object sender, System.EventArgs e)
             {
                    dis(2,1,pictureBox12);
             }
             private void pictureBox13_Click(object sender, System.EventArgs e)
             {
                    dis(2,2,pictureBox13);
             }
             private void pictureBox14_Click(object sender, System.EventArgs e)
             {
                    dis(2,3,pictureBox14);
             }
             private void pictureBox15_Click(object sender, System.EventArgs e)
             {
                    dis(2,4,pictureBox15);
             }
             private void pictureBox16_Click(object sender, System.EventArgs e)
             {
                    dis(3,0,pictureBox16);
             }
             private void pictureBox17_Click(object sender, System.EventArgs e)
             {
                    dis(3,1,pictureBox17);
             }
             private void pictureBox18_Click(object sender, System.EventArgs e)
             {
                    dis(3,2,pictureBox18);
             }
             private void pictureBox19_Click(object sender, System.EventArgs e)
             {
                    dis(3,3,pictureBox19);
             }
             private void pictureBox20_Click(object sender, System.EventArgs e)
             {
                    dis(3,4,pictureBox20);
             }
             private void timer1_Tick(object sender, System.EventArgs e)
             {
                    if(C2!=C1)
                    {
                           img1.Image = new Bitmap("image/bg.jpg");
                           img2.Image = new Bitmap("image/bg.jpg");
                           timer1.Enabled=false;
                    }
             }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            About ab = new About();
            ab.ShowDialog();
        }
       }
}

No hay comentarios.:

Publicar un comentario