C# ile Amiral Battı Oyunu

Bu derste kendi tasarladığım 2 kişilik Amiral Battı oyununu kodları satır satır değil de, fonksiyon fonksiyon anlatacağım. Fonksiyonları incelediğinizde eminim ne yapmak istediğimi anlayacaksınız.

Merhaba Arkadaşlar,

Bu derste kendi tasarladığım 2 kişilik Amiral Battı oyununu kodları satır satır değil de, fonksiyon fonksiyon anlatacağım. Fonksiyonları incelediğinizde eminim ne yapmak istediğimi anlayacaksınız.

Öncelikle çalışma mantığını söyleyeyim daha sonra kodları eklerim.

Formumuzda 2 adet Gridview [10x10] bulunmakta. Her bir oyuncu için 1,2,3,4 boyutlarındaki araçlarımız Random yerleştiriliyor. Aşağıdaki ListBox'lara yaptığınız atışların isabetliliği hakkında bilgiler veriliyor. Oyunculardan hangisi ilk önce tüm araçları bulursa oyunu o kazanıyor. Player1'in vurduğu araçlar a, Player2'nin vurdukları b olarak geçiyor.İlk önce Form1.cs sayfasının kodlarını ekliyorum.


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Web;



namespace ABGrid

{

    public partial class Form1 : Form

    {

        public static string s11 = "x";

        public static string s21 = "x";



        public static int isabetliAtis1 = 0;

        public static int isabetliAtis2 = 0;

        

        public static string sClick1 = "";

        public static int row1;

        public static int col1;



        public static string sClick2 = "";

        public static int row2;

        public static int col2;



        public Form1()

        {

            InitializeComponent();

        }



        private void Form1_Load(object sender, EventArgs e)

        {

            ReStartGame();

        }



        private void ReStartGame() 

        {

            isabetliAtis1 = 0;

            isabetliAtis2 = 0;

            lbPlayer1.ForeColor = SystemColors.WindowText;

            lbPlayer2.ForeColor = SystemColors.WindowText;

            bPlayer1.BackColor = Color.Red;

            bPlayer2.BackColor = SystemColors.GradientInactiveCaption;

            dataGridView1.BackgroundColor = SystemColors.GradientInactiveCaption;

            dataGridView2.BackgroundColor = SystemColors.GradientInactiveCaption;

            dataGridView1.Enabled = true;

            dataGridView2.Enabled = false;



            grid1Doldur();

            grid2Doldur();

        }



        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)

        {

            row1 = dataGridView1.SelectedCells[0].RowIndex;

            col1 = dataGridView1.SelectedCells[0].ColumnIndex;

            sClick1 = dataGridView1.SelectedCells[0].Value.ToString();



            if (dataGridView1.Rows[row1].Cells[col1].Style.ForeColor == Color.DarkGreen || dataGridView1.Rows[row1].Cells[col1].Style.ForeColor == Color.Red)

            {

                MessageBox.Show("Lütfen açılmamış bir hedef seçiniz...", "Bilgi [!]");

            }

            else

            {

                string message = "";

                bPlayer2.BackColor = Color.Red;

                bPlayer1.BackColor = SystemColors.GradientInactiveCaption;

                dataGridView1.Enabled = false;

                dataGridView2.Enabled = true;

                dataGridView1.Rows[0].Cells[0].Value = s11.ToString();



                if ("a".ToString() == dataGridView1.Rows[row1].Cells[col1].Value.ToString())

                {

                    dataGridView1.Rows[row1].Cells[col1].Style.ForeColor = Color.DarkGreen;

                    dataGridView1.Rows[row1].Cells[col1].Style.BackColor = Color.White;

                    int atis = atisKontrol(dataGridView1, row1, col1, "a");

                    if (atis == 0)

                    {

                        message = "- İsabetli bir atış yaptınız...";

                        lbPlayer1.Items.Insert(0, message);

                        isabetliAtis1++;

                    }

                    else

                    {

                        message = "- İsabetli bir atış yaptınız...";

                        lbPlayer1.Items.Insert(0, message);

                        message = "[*]- Bir gemi batırdınız...";

                        lbPlayer1.Items.Insert(0, message);

                        isabetliAtis1++;

                        if (isabetliAtis1 == 10)

                        {

                            MessageBox.Show("Oyuncu 1 Oyunu Kazandı...", "Tebrikler!");

                            dataGridView1.Enabled = false;

                            dataGridView2.Enabled = false;

                        }

                    }

                }

                else

                {

                    dataGridView1.Rows[row1].Cells[col1].Style.ForeColor = Color.Red;

                    dataGridView1.Rows[row1].Cells[col1].Style.BackColor = Color.Black;

                    message = "İsabetsiz bir atış yaptınız...";

                    lbPlayer1.Items.Insert(0, message);

                }



            }

        }



        private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)

        {

            row2 = dataGridView2.SelectedCells[0].RowIndex;

            col2 = dataGridView2.SelectedCells[0].ColumnIndex;

            sClick2 = dataGridView2.SelectedCells[0].Value.ToString();



            if (dataGridView2.Rows[row2].Cells[col2].Style.ForeColor == Color.DarkGreen || dataGridView2.Rows[row2].Cells[col2].Style.ForeColor == Color.Red)

            {

                MessageBox.Show("Lütfen açılmamış bir hedef seçiniz...", "Bilgi [!]");

            }

            else

            {

                string message = "";

                bPlayer1.BackColor = Color.Red;

                bPlayer2.BackColor = SystemColors.GradientInactiveCaption;

                dataGridView2.Enabled = false;

                dataGridView1.Enabled = true;

                dataGridView2.Rows[0].Cells[0].Value = s21.ToString();



                if ("b".ToString() == dataGridView2.Rows[row2].Cells[col2].Value.ToString())

                {

                    dataGridView2.Rows[row2].Cells[col2].Style.ForeColor = Color.DarkGreen;

                    dataGridView2.Rows[row2].Cells[col2].Style.BackColor = Color.White;

                    int atis = atisKontrol(dataGridView2, row2, col2, "b");

                    if (atis == 0)

                    {

                        message = "- İsabetli bir atış yaptınız...";

                        lbPlayer2.Items.Insert(0, message);

                        isabetliAtis2++;

                    }

                    else

                    {

                        message = "- İsabetli bir atış yaptınız...";

                        lbPlayer2.Items.Insert(0, message);

                        message = "[*]- Bir gemi batırdınız...";

                        lbPlayer2.Items.Insert(0, message);

                        isabetliAtis2++;

                        if (isabetliAtis2 == 10)

                        {

                            MessageBox.Show("Oyuncu 2 Oyunu Kazandı...", "Tebrikler!");

                            dataGridView1.Enabled = false;

                            dataGridView2.Enabled = false;

                        }

                    }

                }

                else

                {

                    dataGridView2.Rows[row2].Cells[col2].Style.ForeColor = Color.Red;

                    dataGridView2.Rows[row2].Cells[col2].Style.BackColor = Color.Black;

                    message = "İsabetsiz bir atış yaptınız...";

                    lbPlayer2.Items.Insert(0, message);

                }



            }

        }



        private void grid1Doldur() 

        {

            DataTable dt = new DataTable();

            DataRow dRow;

            DataColumn dColumn;



            for (int i = 0; i < 11; i++)

            {

                dColumn = new DataColumn(i.ToString());

                dt.Columns.Add(dColumn);

            }

            for (int j = 0; j < 11; j++)

            {

                dRow = dt.NewRow();

                dt.Rows.Add(dRow);

            }

            dataGridView1.DataSource = dt;

            for (int m = 0; m < 11; m++)

            {

                for (int n = 0; n < 11; n++)

                {

                    dataGridView1.Rows[m].Cells[n].Style.BackColor = Color.Beige;

                    dataGridView1.Columns[n].Width = 20;

                }

            }



            Random filo1 = new Random();



            int row;

            int col;



            for (int i = 1; i < 5; i++)

            {

                row = filo1.Next(0, 10);

                col = filo1.Next(0, 10);

                while (!(uygunlukKontrol(dataGridView1, "a", row, col, i)))

                {

                    row = filo1.Next(0, 10);

                    col = filo1.Next(0, 10);

                }

                aracYerlestir(dataGridView1, "a", row, col, i);

            }



            for (int j = 0; j < 11; j++)

            {

                for (int m = 0; m < 11; m++)

                {

                    if (dataGridView1.Rows[j].Cells[m].Value.ToString() != "a".ToString())

                    {

                        dataGridView1.Rows[j].Cells[m].Value = "x";

                    }

                    dataGridView1.Rows[j].Cells[m].Style.ForeColor = SystemColors.GradientInactiveCaption;

                    dataGridView1.Rows[j].Cells[m].Style.BackColor = SystemColors.GradientInactiveCaption;

                }

            }

            s11 = dataGridView1.Rows[0].Cells[0].Value.ToString();

            dataGridView1.Rows[0].Cells[0].Value = "";

        }



        private void grid2Doldur() 

        {

            DataTable dt = new DataTable();

            DataRow dRow;

            DataColumn dColumn;



            for (int i = 0; i < 11; i++)

            {

                dColumn = new DataColumn(i.ToString());

                dt.Columns.Add(dColumn);

            }

            for (int j = 0; j < 11; j++)

            {

                dRow = dt.NewRow();

                dt.Rows.Add(dRow);

            }

            dataGridView2.DataSource = dt;

            for (int m = 0; m < 11; m++)

            {

                for (int n = 0; n < 11; n++)

                {

                    dataGridView2.Rows[m].Cells[n].Style.BackColor = Color.Beige;

                    dataGridView2.Columns[n].Width = 20;

                }

            }



            Random filo2 = new Random();



            int row;

            int col;



            for (int i = 1; i < 5; i++)

            {

                row = filo2.Next(0, 10);

                col = filo2.Next(0, 10);

                while (!(uygunlukKontrol(dataGridView2, "b", row, col, i)))

                {

                    row = filo2.Next(0, 10);

                    col = filo2.Next(0, 10);

                }

                aracYerlestir(dataGridView2, "b", row, col, i);

            }



            for (int j = 0; j < 11; j++)

            {

                for (int m = 0; m < 11; m++)

                {

                    if (dataGridView2.Rows[j].Cells[m].Value.ToString() != "b".ToString())

                    {

                        dataGridView2.Rows[j].Cells[m].Value = "x";

                    }

                    dataGridView2.Rows[j].Cells[m].Style.ForeColor = SystemColors.GradientInactiveCaption;

                    dataGridView2.Rows[j].Cells[m].Style.BackColor = SystemColors.GradientInactiveCaption;

                }

            }

            s21 = dataGridView2.Rows[0].Cells[0].Value.ToString();

            dataGridView2.Rows[0].Cells[0].Value = "";

        }



        /// <summary>

        /// verilen indis te taşma olup olmadığını ve o satırda başka araç olup olmadığını kontrol eder.

        /// </summary>

        private bool uygunlukKontrol(DataGridView gr,string controler, int row, int col, int boyut)

        {

            if (col + boyut > 10)

            {

                return false;

            }

            else

            {

                for (int i = 0; i < 10; i++)

                {

                    if (gr.Rows[row].Cells.Value.ToString() == controler)

                    {

                        return false;

                    }

                }

            }

            return true;

        }

        /// <summary>

        /// uygunluğu kontrol edilen indexlere yerleştiriliyor araç.

        /// </summary>

        public void aracYerlestir(DataGridView gr, string controler, int row, int col, int boyut)

        {

            for (int i = 0; i < boyut; i++)

            {

                gr.Rows[row].Cells[col + i].Value = controler;

            }

        }

        /// <summary>

        /// Yapılan başarılı atış sonucu geminin tamamen battığı mı yoksa kısmen vurulduğu mu kontrol ediliyor.0=Vuruldu,1=Tamamen Battı.

        /// </summary>

        private int atisKontrol(DataGridView gr, int row, int col, string controler)

        {

            if (col == 0)

            {

                for (int j = 1; j < 4; j++)

                {

                    if (gr.Rows[row].Cells[col + j].Value.ToString() == controler && gr.Rows[row].Cells[col + j].Style.ForeColor == SystemColors.GradientInactiveCaption)

                    {

                        return 0;

                    }

                }

                return 1;

            }

            else if (col == 10)

            {

                for (int i = 1; i < 4; i++)

                {

                    if (gr.Rows[row].Cells[col - i].Value.ToString() == controler && gr.Rows[row].Cells[col - i].Style.ForeColor == SystemColors.GradientInactiveCaption)

                    {

                        return 0;

                    }

                }

                return 1;

            }

            else

            {

                int b = 4;

                if (10 - col < b)

                {

                    b = (10 - col) + 1;

                }

                else if (col < b)

                {

                    b = col + 1;

                }

                for (int m = 1; m < b; m++)

                {

                    if ((gr.Rows[row].Cells[col - m].Value.ToString() == controler && gr.Rows[row].Cells[col - m].Style.ForeColor == SystemColors.GradientInactiveCaption)

                        || (gr.Rows[row].Cells[col + m].Value.ToString() == controler && gr.Rows[row].Cells[col + m].Style.ForeColor == SystemColors.GradientInactiveCaption))

                    {

                        return 0;

                    }

                }

                return 1;

            }

            // 0 = Vuruldu ama ölmedi, 1 = Vuruldu ve öldü...

        }



        private void button1_Click(object sender, EventArgs e)

        {

            ReStartGame();

            lbPlayer1.Items.Clear();

            lbPlayer2.Items.Clear();

        }



    }

}



Aslında fonksiyon isimlerinden hangisinin ne işe yaradığını bulmanız çok kolay,zaten isimlendirme yaparken görevini düşünerek yaptım.

Şimdi de Form1.Designer.cs sayfasının kodlarını veriyorum.Bu sayfa formumdaki gridview,listbox ve butonların stillerini tutuyor.Burdan aynı tasarımı elde edebilirsiniz.


namespace ABGrid

{

    partial class Form1

    {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.IContainer components = null;



        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

        protected override void Dispose(bool disposing)

        {

            if (disposing && (components != null))

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }



        #region Windows Form Designer generated code



        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();

            this.dataGridView1 = new System.Windows.Forms.DataGridView();

            this.dataGridView2 = new System.Windows.Forms.DataGridView();

            this.lbPlayer1 = new System.Windows.Forms.ListBox();

            this.lbPlayer2 = new System.Windows.Forms.ListBox();

            this.button1 = new System.Windows.Forms.Button();

            this.bPlayer1 = new System.Windows.Forms.Button();

            this.bPlayer2 = new System.Windows.Forms.Button();

            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();

            this.SuspendLayout();

            // 

            // dataGridView1

            // 

            this.dataGridView1.AllowUserToAddRows = false;

            this.dataGridView1.AllowUserToDeleteRows = false;

            this.dataGridView1.AllowUserToResizeColumns = false;

            this.dataGridView1.AllowUserToResizeRows = false;

            this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)

                        | System.Windows.Forms.AnchorStyles.Right)));

            this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.GradientInactiveCaption;

            this.dataGridView1.CausesValidation = false;

            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;

            dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;

            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;

            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;

            this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;

            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;

            this.dataGridView1.ColumnHeadersVisible = false;

            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;

            dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;

            dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;

            dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

            dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;

            this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle2;

            this.dataGridView1.Location = new System.Drawing.Point(12, 12);

            this.dataGridView1.MultiSelect = false;

            this.dataGridView1.Name = "dataGridView1";

            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;

            dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;

            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;

            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;

            this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;

            this.dataGridView1.RowHeadersVisible = false;

            this.dataGridView1.ShowCellErrors = false;

            this.dataGridView1.ShowCellToolTips = false;

            this.dataGridView1.ShowEditingIcon = false;

            this.dataGridView1.ShowRowErrors = false;

            this.dataGridView1.Size = new System.Drawing.Size(224, 245);

            this.dataGridView1.TabIndex = 0;

            this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);

            // 

            // dataGridView2

            // 

            this.dataGridView2.AllowUserToAddRows = false;

            this.dataGridView2.AllowUserToDeleteRows = false;

            this.dataGridView2.AllowUserToResizeColumns = false;

            this.dataGridView2.AllowUserToResizeRows = false;

            this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)

                        | System.Windows.Forms.AnchorStyles.Right)));

            this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.GradientInactiveCaption;

            this.dataGridView2.CausesValidation = false;

            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;

            dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;

            dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;

            dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

            dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;

            this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;

            this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;

            this.dataGridView2.ColumnHeadersVisible = false;

            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window;

            dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText;

            dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;

            dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

            dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;

            this.dataGridView2.DefaultCellStyle = dataGridViewCellStyle5;

            this.dataGridView2.Location = new System.Drawing.Point(242, 12);

            this.dataGridView2.MultiSelect = false;

            this.dataGridView2.Name = "dataGridView2";

            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;

            dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;

            dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;

            dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

            dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;

            this.dataGridView2.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;

            this.dataGridView2.RowHeadersVisible = false;

            this.dataGridView2.ShowCellErrors = false;

            this.dataGridView2.ShowCellToolTips = false;

            this.dataGridView2.ShowEditingIcon = false;

            this.dataGridView2.ShowRowErrors = false;

            this.dataGridView2.Size = new System.Drawing.Size(223, 245);

            this.dataGridView2.TabIndex = 0;

            this.dataGridView2.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellClick);

            // 

            // lbPlayer1

            // 

            this.lbPlayer1.FormattingEnabled = true;

            this.lbPlayer1.Location = new System.Drawing.Point(12, 310);

            this.lbPlayer1.Name = "lbPlayer1";

            this.lbPlayer1.Size = new System.Drawing.Size(224, 238);

            this.lbPlayer1.TabIndex = 2;

            // 

            // lbPlayer2

            // 

            this.lbPlayer2.FormattingEnabled = true;

            this.lbPlayer2.Location = new System.Drawing.Point(242, 311);

            this.lbPlayer2.Name = "lbPlayer2";

            this.lbPlayer2.Size = new System.Drawing.Size(224, 238);

            this.lbPlayer2.TabIndex = 3;

            // 

            // button1

            // 

            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

            this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            this.button1.Location = new System.Drawing.Point(12, 555);

            this.button1.Name = "button1";

            this.button1.Size = new System.Drawing.Size(454, 43);

            this.button1.TabIndex = 4;

            this.button1.Text = "Yeni Oyun Başlat";

            this.button1.UseVisualStyleBackColor = true;

            this.button1.Click += new System.EventHandler(this.button1_Click);

            // 

            // bPlayer1

            // 

            this.bPlayer1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

            this.bPlayer1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            this.bPlayer1.Location = new System.Drawing.Point(12, 263);

            this.bPlayer1.Name = "bPlayer1";

            this.bPlayer1.Size = new System.Drawing.Size(224, 42);

            this.bPlayer1.TabIndex = 7;

            this.bPlayer1.Text = "Oyuncu 1";

            this.bPlayer1.UseVisualStyleBackColor = true;

            // 

            // bPlayer2

            // 

            this.bPlayer2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

            this.bPlayer2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));

            this.bPlayer2.Location = new System.Drawing.Point(242, 263);

            this.bPlayer2.Name = "bPlayer2";

            this.bPlayer2.Size = new System.Drawing.Size(224, 42);

            this.bPlayer2.TabIndex = 8;

            this.bPlayer2.Text = "Oyuncu 2";

            this.bPlayer2.UseVisualStyleBackColor = true;

            // 

            // Form1

            // 

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;

            this.ClientSize = new System.Drawing.Size(477, 607);

            this.Controls.Add(this.bPlayer2);

            this.Controls.Add(this.bPlayer1);

            this.Controls.Add(this.button1);

            this.Controls.Add(this.lbPlayer2);

            this.Controls.Add(this.lbPlayer1);

            this.Controls.Add(this.dataGridView2);

            this.Controls.Add(this.dataGridView1);

            this.MaximizeBox = false;

            this.Name = "Form1";

            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

            this.Text = "Amiral Battı [v1]";

            this.Load += new System.EventHandler(this.Form1_Load);

            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();

            this.ResumeLayout(false);



        }



        #endregion



        private System.Windows.Forms.DataGridView dataGridView1;

        private System.Windows.Forms.DataGridView dataGridView2;

        private System.Windows.Forms.ListBox lbPlayer1;

        private System.Windows.Forms.ListBox lbPlayer2;

        private System.Windows.Forms.Button button1;

        private System.Windows.Forms.Button bPlayer1;

        private System.Windows.Forms.Button bPlayer2;

    }

}



Resim eklemek isterdim ama maalesef yapamıyorum. Takıldığınız bir yer olursa sormaktan çekinmeyin...

İyi çalışmalar...
  • Etiketler;
Murat Karakoyun
İstanbul Üniversitesi Bilgisayar Mühendisliği bölümü mezunu. Şu anda özel bir firmanın Bilgi İşlem ve Yazılım Geliştirme departmanında çalışıyor. Asp.Net (CSharp), MsSQL, HTML, CSS, Photoshop biliyor.
Yorum Yaz

Yorum yazabilmek için üye girişi yapmanız gerekiyor!

üstteki kodlarda yani using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Web; burda linq kısmında hata verdi.Nasıl düzeltebilirim?
Merhaba, Nasıl bir hata alıyorsun,yazabilir misin sana zahmet? İyi çalışmalar...
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Web; şu kodlardan yani form1.cs deki kodların başlangıcındaki using system.linq te hata veriyor hata türü böyle The type or namespace name 'Linq' does not exist in the namespace 'System' böyle bir hata veriyor c# a daha yeni başladığım için hatayı anlamadım.
Framework 3.5 ile hazırladım projeyi,sendeki framework farklı olduğundan hata veriyor diye düşünüyorum.System.Linq,.Net Framework 3.5 ta olan System.Core.dll'de bulunuyormuş.
usTa'm kusura bakma da bi resimlisini atsanız..s yeniyiz
Ya aslında ben de tüm dersleri resimli eklemek istiyorum;ama maalesef iş yerinde baya baya kısıtlama var networkte.Evde de maalesef şimdilik net olmadığı için bu şekilde yazmaya çalışıyorum.Yalnız eklediğim derslerin kaynak kodlarını isteyen arkadaşlar olursa,özelden mesaj yazıp maillerini verseler ben onlara yollarım...
Kardeşim kodlar duruyorsa bana gönderebilir misin ? Çok acil lazımda.

Yukarı Git