Download the game interface click on Download Download
This is the version of tic tac toe 1.1 you can really like it by playing this.So play and enjoy the game soon you will play better then this game in tic tac toe 1.2.
for download tic tac toe 1.1 download from here
Download
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;
namespace @game
{
public partial
class Form1
: Form
{
public Form1()
{
InitializeComponent();
}
int i;
//reset function
public void
reset()
{
button1.BackColor =
button2.BackColor=
button3.BackColor = button4.BackColor=
button5.BackColor=
button6.BackColor=
button7.BackColor=
button8.BackColor=
button9.BackColor=Color.White;
textBox1.Text = textBox2.Text = "";
label4.Text = "";
button12.Show();
button1.Enabled = button2.Enabled =
button3.Enabled = button4.Enabled =
button5.Enabled = button6.Enabled =
button7.Enabled = button8.Enabled =
button9.Enabled = true;
button1.Text = button2.Text =
button3.Text = button4.Text =
button5.Text = button6.Text =
button7.Text = button8.Text =
button9.Text = "";
i = 0;
}
//for hiding all buttons
public void
buttonhide()
{
button1.Hide();
button2.Hide();
button3.Hide();
button4.Hide();
button5.Hide();
button6.Hide();
button7.Hide();
button8.Hide();
button9.Hide();
label1.Text = "Its a Draw...";
label1.Show();
}
//button 1 coding
private void
button1_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == ""||label4.Text==""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button1.Text == "")
if
(i % 2 == 0)
{
button1.Enabled = false;
button12.Hide();
button1.Text = "X";
label4.Text =
(textBox2.Text+"'s Turn");
}
else
{
button1.Enabled = false;
button12.Hide();
button1.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button2.Text == button1.Text && button3.Text == button1.Text)
{
button1.BackColor =
button2.BackColor = button3.BackColor = Color.Green;
if
(button1.Text == "X")
MessageBox.Show(" "
+ textBox1.Text + " Won the Game");
else
MessageBox.Show(" "
+ textBox2.Text + " Won the Game");
reset();
}
else
if (button4.Text == button1.Text &&
button7.Text == button1.Text)
{
button1.BackColor = button4.BackColor
= button7.BackColor = Color.Green;
if
(button1.Text == "X")
MessageBox.Show(" "
+ textBox1.Text + " Won the Game");
else
MessageBox.Show(" "
+ textBox2.Text + " Won the Game");
reset();
}
else
if (button5.Text == button1.Text &&
button9.Text ==button1.Text)
{
button1.BackColor =
button5.BackColor = button9.BackColor = Color.Green;
if
(button1.Text == "X")
MessageBox.Show(" "
+ textBox1.Text + " Won the Game");
else
MessageBox.Show(" "
+ textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button 2 coding
private void
button2_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if (i < 9 && button2.Text == "")
if
(i % 2 == 0)
{
button2.Enabled = false;
button12.Hide();
button2.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button2.Enabled = false;
button12.Hide();
button2.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button1.Text == button2.Text && button3.Text == button2.Text)
{
button1.BackColor =
button2.BackColor = button3.BackColor = Color.Green;
if
(button2.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button5.Text == button2.Text &&
button8.Text == button2.Text)
{
button5.BackColor =
button2.BackColor = button8.BackColor = Color.Green;
if
(button2.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button 3 coding
private void
button3_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button3.Text == "")
if
(i % 2 == 0)
{
button3.Enabled = false;
button12.Hide();
button3.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button3.Enabled = false;
button12.Hide();
button3.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button1.Text == button3.Text && button2.Text == button3.Text)
{
button1.BackColor =
button2.BackColor = button3.BackColor = Color.Green;
if
(button3.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button6.Text == button3.Text &&
button9.Text == button3.Text)
{
button6.BackColor =
button9.BackColor = button3.BackColor = Color.Green;
if
(button3.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button7.Text == button3.Text &&
button5.Text == button3.Text)
{
button5.BackColor =
button7.BackColor = button3.BackColor = Color.Green;
if
(button3.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" "
+ textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button 4 coding
private void
button4_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button4.Text == "")
if
(i % 2 == 0)
{
button4.Enabled = false;
button12.Hide();
button4.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button4.Enabled = false;
button12.Hide();
button4.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button1.Text == button4.Text && button7.Text == button4.Text)
{
button1.BackColor =
button4.BackColor = button7.BackColor = Color.Green;
if
(button4.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button5.Text == button4.Text &&
button6.Text == button4.Text)
{
button5.BackColor =
button4.BackColor = button6.BackColor = Color.Green;
if
(button4.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button 5 coding
private void
button5_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button5.Text == "")
if (i % 2 == 0)
{
button5.Enabled = false;
button12.Hide();
button5.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button5.Enabled = false;
button12.Hide();
button5.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button2.Text == button5.Text && button8.Text == button5.Text)
{
button5.BackColor =
button2.BackColor = button8.BackColor = Color.Green;
if (button5.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button4.Text == button5.Text &&
button6.Text == button5.Text)
{
button4.BackColor =
button5.BackColor = button6.BackColor = Color.Green;
if
(button5.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button7.Text == button5.Text &&
button3.Text == button5.Text)
{
button7.BackColor =
button5.BackColor = button3.BackColor = Color.Green;
if
(button5.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button1.Text == button5.Text &&
button9.Text == button5.Text)
{
button1.BackColor =
button5.BackColor = button9.BackColor = Color.Green;
if
(button5.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button 6 coding
private void
button6_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button6.Text == "")
if (i %
2 == 0)
{
button6.Enabled = false;
button12.Hide();
button6.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button6.Enabled = false;
button12.Hide();
button6.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button4.Text == button6.Text && button5.Text == button6.Text)
{
button4.BackColor =
button6.BackColor = button5.BackColor = Color.Green;
if
(button6.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button3.Text == button6.Text &&
button9.Text == button6.Text)
{
button3.BackColor =
button6.BackColor = button9.BackColor = Color.Green;
if
(button6.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button
7 coding
private void
button7_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button7.Text == "")
if
(i % 2 == 0)
{
button7.Enabled = false;
button12.Hide();
button7.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button7.Enabled = false;
button12.Hide();
button7.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button1.Text == button7.Text && button4.Text == button7.Text)
{
button1.BackColor =
button7.BackColor = button4.BackColor = Color.Green;
if
(button7.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button8.Text == button7.Text &&
button9.Text == button7.Text)
{
button8.BackColor =
button7.BackColor = button9.BackColor = Color.Green;
if
(button7.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" "
+ textBox2.Text + " Won the Game");
reset();
}
else
if (button5.Text == button7.Text &&
button3.Text == button7.Text)
{
button5.BackColor =
button7.BackColor = button3.BackColor = Color.Green;
if
(button7.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" "
+ textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
private void
button8_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button8.Text == "")
if
(i % 2 == 0)
{
button8.Enabled = false;
button12.Hide();
button8.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button8.Enabled = false;
button12.Hide();
button8.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button7.Text == button8.Text && button9.Text == button8.Text)
{
button7.BackColor =
button8.BackColor = button9.BackColor = Color.Green;
if
(button8.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button5.Text == button8.Text &&
button2.Text == button8.Text)
{
button5.BackColor =
button2.BackColor = button8.BackColor = Color.Green;
if
(button8.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//button 9 coding
private void
button9_Click(object sender, EventArgs e)
{
if
((textBox1.Text == "" ||
textBox2.Text == "" || label4.Text
== ""))
MessageBox.Show("Please click on Start");
else
{
if
(i < 9 && button9.Text == "")
if
(i % 2 == 0)
{
button9.Enabled = false;
button12.Hide();
button9.Text = "X";
label4.Text =
(textBox2.Text + "'s Turn");
}
else
{
button9.Enabled = false;
button12.Hide();
button9.Text = "O";
label4.Text =
(textBox1.Text + "'s Turn");
}
i++;
if
(button3.Text == button9.Text && button6.Text == button9.Text)
{
button9.BackColor =
button6.BackColor = button3.BackColor = Color.Green;
if
(button9.Text == "X")
MessageBox.Show(" "
+ textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button7.Text == button9.Text &&
button8.Text == button9.Text)
{
button7.BackColor =
button8.BackColor = button9.BackColor = Color.Green;
if
(button9.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (button1.Text == button9.Text &&
button5.Text == button9.Text)
{
button1.BackColor =
button9.BackColor = button5.BackColor = Color.Green;
if
(button9.Text == "X")
MessageBox.Show(" " + textBox1.Text + " Won the Game");
else
MessageBox.Show(" " + textBox2.Text + " Won the Game");
reset();
}
else
if (i == 9)
{
buttonhide(); //calling
buttonhide function
reset(); //calling
reset function
}
}
}
//play again coding to show all buttons again
private void
button10_Click(object sender, EventArgs e)
{
button1.Show();
button2.Show();
button3.Show();
button4.Show();
button5.Show();
button6.Show();
button7.Show();
button8.Show();
button9.Show();
label1.Hide();
reset();
}
//quit button
private void
button11_Click(object sender, EventArgs e)
{
this.Close();
}
//Start button coding
private void
button12_Click(object sender, EventArgs e)
{
if
(textBox1.Text == "" ||
textBox2.Text == "")
MessageBox.Show("Player Name Cannot be blank");
else if (label1.Text == "Its a Draw...")
MessageBox.Show("Click on Play again option");
else if (label1.Text == "Its a Draw...")
MessageBox.Show("Click on Play again option");
else
label4.Text = (textBox1.Text + "'s Turn");
}
}
}
Want to download this game click here
Output
itss owsm SIR.....i wnna see sm more mini games in window by you...!! thnx to give us direction!!
ReplyDeletekya baat hai sir aap to cha gye!!!!!!!!!!!!!!!!!!!!
ReplyDelete