AÇIKLAMA
C# dilinde yazılan bu programda amaç koordinatları verilen bir atın oynayabileceği yerlerin bulunmasıdır.
Programın Tamamını Aşağıdaki Linkten İndirebilirsiniz
Linki Görebilmeniz İçin Üye Olmanız Gerekmektedir...
Üye Kayıt
Program Kodu:
using System; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; namespace Santranc { public partial class Form1 : Form { Chess a = new Chess(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { a.Parent = this; a.Bounds = new Rectangle(20,20,600,600); } } } using System; using System.Linq; using System.Text; using System.Drawing; namespace Santranc { public class Chess : FlowLayoutPanel { Image horse = Image.FromFile("At.jpg"); Button[] butonlar = new Button[81]; private int horseIndex = 0; public Chess() { this.BackColor = Color.RoyalBlue; int solduzlem = 8; int altduzlem = 1; for (int i = 0; i < 81; i++ ) { button = new Button(); if (i % 9 == 0 || i > 71) { button.BackColor = Color.Tomato; if (i < 71) { button.Text = solduzlem.ToString(); solduzlem--; } else if (i > 72) { button.Text =Convert.ToChar(altduzlem + 64).ToString(); altduzlem++; } } else if (i % 2 == 0) { button.BackColor = Color.Black; } else { button.BackColor = Color.White; } if (i == 65) { button.BackgroundImage = horse; horseIndex = i; } this.Controls.Add(button); button.Tag = i; butonlar[i] = button; } } public void button_Click(object sender, EventArgs e) { Button tik = (Button)sender; int a = Convert.ToInt32(tik.Tag); if (a % 9 != 0 && a < 72) { if (a - horseIndex == -7 || a - horseIndex == 7 || a - horseIndex == -11 || a - horseIndex == 11 || a - horseIndex == -17 || a - horseIndex == 17 || a - horseIndex == -19 || a - horseIndex == 19) { butonlar[horseIndex].BackgroundImage = null; tik.BackgroundImage = horse; horseIndex = a; } else { MessageBox.Show("Geçersiz Hamle"); } } } } }