Arama butonu
Bu konudaki kullanıcılar: 1 misafir
0
Cevap
313
Tıklama
0
Öne Çıkarma
Bu kodlar ne iş yapar
G
8 yıl
Onbaşı
Konu Sahibi

Yabancı bi steden yaptım bu tictactoe oyununu ama kodları anlamada sıkıntılarım var açıklayabilecek olan varmı bu kodları arkadaşlar

namespace wf_tictactoe
{
public partial class Form1 : Form
{
bool turn = true;
int turn_count = 0;

public Form1()
{
InitializeComponent();
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Bu Oyun Öğrenciler Tarafından Hazırlanmıştır");
}

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

}

private void button_click(object sender, EventArgs e)
{
Button b = (Button)sender;
if (turn)
b.Text = "X";
else
b.Text = "O";

turn = !turn;
b.Enabled = false;
turn_count++;

checkForWinner();
}

private void checkForWinner()
{
bool there_is_a_winner = false;
//HORİZONTAL CHECKS
if((A1.Text==A2.Text)&&(A2.Text==A3.Text)&&(!A1.Enabled))
there_is_a_winner=true;
else if ((B1.Text == B2.Text) && (B2.Text == B3.Text) && (!B1.Enabled))
there_is_a_winner = true;
else if ((C1.Text == C2.Text) && (C2.Text == C3.Text) && (!C1.Enabled))
there_is_a_winner = true;

//VERTİCAL CHECKS
else if ((A1.Text == B1.Text) && (B1.Text == C1.Text) && (!A1.Enabled))
there_is_a_winner = true;
else if ((A2.Text == B2.Text) && (B2.Text == C2.Text) && (!A2.Enabled))
there_is_a_winner = true;
else if ((A3.Text == B3.Text) && (B3.Text == C3.Text) && (!A3.Enabled))
there_is_a_winner = true;

//DİAGONAL CHECKS
else if ((A1.Text == B2.Text) && (B2.Text == C3.Text) && (!A1.Enabled))
there_is_a_winner = true;
else if ((A3.Text == B2.Text) && (B2.Text == C1.Text) && (!C1.Enabled))

there_is_a_winner = true;

if (there_is_a_winner)
{
disableButtons();

string winner = "";
if (turn)
winner = "O";
else
winner = "X";
MessageBox.Show(winner+ " KAZANDI"," Yay");
}
else
{
if (turn_count==9)
MessageBox.Show("BERABERE","Bummer");
}

}

private void disableButtons()
{
try
{
foreach (Control c in Controls)
{
Button b = (Button)c;
b.Enabled = false;
}
}
catch { }
}

private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
{
turn = true;
turn_count = 0;

try
{
foreach (Control c in Controls)
{
Button b = (Button)c;
b.Enabled = true;
b.Text = "";
}
}
catch { }
}


}
}





< Bu mesaj bu kişi tarafından değiştirildi gunerkartalova -- 23 Mayıs 2017; 21:42:42 >

DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.