Assalamualaikum sahabat,
kali ini kita akan bermain main dengan game tic tac toe, tau dong atau di indonesia lebih di kenal dengan nama XOX, nah langsung aja ya kita akan membuat program sederhana dari game ini ,seperti biasa kita menggunakan visual c# 2010
ok ini dia program nya
kali ini kita akan bermain main dengan game tic tac toe, tau dong atau di indonesia lebih di kenal dengan nama XOX, nah langsung aja ya kita akan membuat program sederhana dari game ini ,seperti biasa kita menggunakan visual c# 2010
ok ini dia program nya
PRAKTIKUM PEMOGRAMAN
/*
* Created by SharpDevelop.
* User: mhs
* Date: 4/30/2014
* Time: 1:48 PM
*
* To change this template use Tools | Options
| Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Media;
namespace Tic_Tac_Toe
{
/// <summary>
/// Description of
MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows
Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the
InitializeComponent() call.
//
}
int turn=1;
int
click1=0,click2=0,click3=0,click4=0,click5=0,click6=0,click7=0,click8=0,click9=0;
int
player1=0,player2=0;
public void display()
{
if(twoPlayer.Checked == true)
{
if(turn%2!=0)
{
disTurn.Text="Player 1 Turn!";
}
else
{
disTurn.Text="Player 2 Turn!";
}
}
else if(vsCom.Checked
== true)
{
if(turn%2!=0)
{
disTurn.Text="Player 1 Turn!";
}
else
{
disTurn.Text="Computer Turn!";
}
}
}
private void
ComPlay()
{
if (button1.Text == "O"
&& button2.Text == "O")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button2.Text == "O"
&& button3.Text == "O")
{
if (button1.Text == "")
{
button1.Text = "O";
checkit();
return;
}
}
if (button1.Text == "O"
&& button3.Text == "O")
{
if (button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button1.Text == "O"
&& button7.Text == "O")
{
if (button4.Text == "")
{
button4.Text = "O";
checkit();
return;
}
}
if (button1.Text == "O"
&& button4.Text == "O")
{
if (button7.Text == "")
{
button7.Text = "O";
checkit();
return;
}
}
if (button4.Text == "O"
&& button7.Text == "O")
{
if (button1.Text == "")
{
button1.Text = "O";
checkit();
return;
}
}
if (button1.Text == "O"
&& button5.Text == "O")
{
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button9.Text == "O")
{
if (button1.Text == "")
{
button1.Text = "O";
checkit();
return;
}
}
if (button1.Text == "O"
&& button9.Text == "O")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button2.Text == "O"
&& button5.Text == "O")
{
if (button8.Text == "")
{
button8.Text = "O";
checkit();
return;
}
}
if (button2.Text == "O"
&& button8.Text == "O")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button8.Text == "O")
{
if
(button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button3.Text == "O"
&& button6.Text == "O")
{
if
(button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button8.Text == "O")
{
if (button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button3.Text == "O"
&& button9.Text == "O")
{
if (button6.Text == "")
{
button6.Text = "O";
checkit();
return;
}
}
if (button6.Text == "O"
&& button9.Text == "O")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button4.Text == "O"
&& button5.Text == "O")
{
if (button4.Text == "")
{
button6.Text = "O";
checkit();
return;
}
}
if
(button4.Text == "O" &&
button6.Text == "O")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button6.Text == "O")
{
if (button4.Text == "")
{
button4.Text = "O";
checkit();
return;
}
}
if (button7.Text == "O"
&& button9.Text == "O")
{
if (button8.Text == "")
{
button8.Text = "O";
checkit();
return;
}
}
if (button8.Text == "O"
&& button9.Text == "O")
{
if (button7.Text == "")
{
button7.Text = "O";
checkit();
return;
}
}
if (button7.Text == "O"
&& button8.Text == "O")
{
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
if (button3.Text == "O"
&& button5.Text == "O")
{
if (button7.Text == "")
{
button7.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button7.Text == "O")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button3.Text == "O"
&& button7.Text == "O")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button1.Text == "X"
&& button2.Text == "X")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button2.Text == "X"
&& button3.Text == "X")
{
if (button1.Text == "")
{
button1.Text = "O";
checkit();
return;
}
}
if (button1.Text == "X"
&& button3.Text == "X")
{
if (button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button1.Text == "X"
&& button4.Text == "X")
{
if (button7.Text == "")
{
button7.Text = "O";
checkit();
return;
}
}
if (button1.Text == "X"
&& button7.Text == "X")
{
if (button4.Text == "")
{
button4.Text = "O";
checkit();
return;
}
}
if (button4.Text == "X"
&& button7.Text == "X")
{
if (button1.Text == "")
{
button1.Text = "O";
checkit();
return;
}
}
if (button1.Text == "X"
&& button9.Text == "X")
{
if
(button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button1.Text == "X"
&& button5.Text == "X")
{
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
if (button5.Text == "X"
&& button9.Text == "X")
{
if (button5.Text == "")
{
button1.Text = "O";
checkit();
return;
}
}
if (button4.Text == "X"
&& button5.Text == "X")
{
if (button6.Text == "")
{
button6.Text = "O";
checkit();
return;
}
}
if (button4.Text == "X"
&& button6.Text == "X")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button5.Text == "X"
&& button6.Text == "X")
{
if (button4.Text == "")
{
button4.Text = "O";
checkit();
return;
}
}
if (button7.Text == "X"
&& button9.Text == "X")
{
if (button8.Text == "")
{
button8.Text = "O";
checkit();
return;
}
}
if (button7.Text == "X"
&& button8.Text == "X")
{
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
if (button8.Text == "X"
&& button9.Text == "X")
{
if (button7.Text == "")
{
button7.Text = "O";
checkit();
return;
}
}
if (button2.Text == "X"
&& button5.Text == "X")
{
if (button8.Text == "")
{
button8.Text = "O";
checkit();
return;
}
}
if (button3.Text == "X"
&& button6.Text == "X")
{
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
if (button5.Text == "X"
&& button7.Text == "X")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button2.Text == "X"
&& button7.Text == "X")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button3.Text == "X"
&& button9.Text == "X")
{
if (button6.Text == "")
{
button6.Text = "O";
checkit();
return;
}
}
if (button6.Text == "X"
&& button9.Text == "X")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button3.Text == "X"
&& button9.Text == "X")
{
if (button6.Text == "")
{
button6.Text = "O";
checkit();
return;
}
}
if (button5.Text == "X"
&& button8.Text == "X")
{
if (button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button3.Text == "X"
&& button5.Text == "X")
{
if (button7.Text == "")
{
button7.Text = "O";
checkit();
return;
}
}
if (button5.Text == "X"
&& button7.Text == "X")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button3.Text == "X"
&& button7.Text == "X")
{
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
}
if (button5.Text == "")
{
button5.Text = "O";
checkit();
return;
}
if (button1.Text == "X"
&& button9.Text == "X"
&& button5.Text == "O")
{
if (button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button3.Text == "X"
&& button7.Text == "X"
&& button5.Text == "O")
{
if (button2.Text == "")
{
button2.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button2.Text == "X")
{
if (button3.Text == "")
{
button3.Text = "O";
checkit();
return;
}
}
if (button5.Text == "O"
&& button8.Text == "X")
{
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
}
// last options if none of the above are false
if (button1.Text == "")
{
button1.Text = "O";
checkit();
return;
}
if (button3.Text == "")
{
button3.Text ="O";
checkit();
return;
}
if (button9.Text == "")
{
button9.Text = "O";
checkit();
return;
}
if (button6.Text == "")
{
button6.Text = "O";
checkit();
return;
}
}
public void checkit()
{
if (button1.Text!=""
&& button2.Text!=""
&& button3.Text!=""
&& button4.Text!=""
&& button5.Text!=""
&& button6.Text!=""
&&
button7.Text!=""
&& button8.Text!=""
&& button9.Text!="")
{
MessageBox.Show("Game Draw!");
cleargame();
}
else if(button1.Text!="" && button2.Text!="" && button3.Text!="")
{
if(button1.Text==button2.Text &&
button1.Text==button3.Text)
{
button1.BackColor=Color.Green;
button1.ForeColor=Color.White;
button2.BackColor=Color.Green;
button2.ForeColor=Color.White;
button3.BackColor=Color.Green;
button3.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button1.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player 2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button1.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button4.Text!=""
&& button5.Text!=""
&& button6.Text!="")
{
if(button4.Text==button5.Text &&
button4.Text==button6.Text)
{
button4.BackColor=Color.Green;
button4.ForeColor=Color.White;
button5.BackColor=Color.Green;
button5.ForeColor=Color.White;
button6.BackColor=Color.Green;
button6.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button4.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button4.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button7.Text!=""
&& button8.Text!=""
&& button9.Text!="")
{
if(button7.Text==button8.Text &&
button7.Text==button9.Text)
{
button7.BackColor=Color.Green;
button7.ForeColor=Color.White;
button8.BackColor=Color.Green;
button8.ForeColor=Color.White;
button9.BackColor=Color.Green;
button9.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button7.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button7.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button1.Text!=""
&& button5.Text!=""
&& button9.Text!="")
{
if(button1.Text==button5.Text &&
button1.Text==button9.Text)
{
button1.BackColor=Color.Green;
button1.ForeColor=Color.White;
button5.BackColor=Color.Green;
button5.ForeColor=Color.White;
button9.BackColor=Color.Green;
button9.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button1.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button1.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button1.Text!=""
&& button4.Text!=""
&& button7.Text!="")
{
if(button1.Text==button4.Text &&
button1.Text==button7.Text)
{
button1.BackColor=Color.Green;
button1.ForeColor=Color.White;
button4.BackColor=Color.Green;
button4.ForeColor=Color.White;
button7.BackColor=Color.Green;
button7.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button1.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button1.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button2.Text!=""
&& button5.Text!=""
&& button8.Text!="")
{
if(button2.Text==button5.Text &&
button2.Text==button8.Text)
{
button2.BackColor=Color.Green;
button2.ForeColor=Color.White;
button5.BackColor=Color.Green;
button5.ForeColor=Color.White;
button8.BackColor=Color.Green;
button8.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button2.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button2.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button3.Text!=""
&& button6.Text!=""
&& button9.Text!="")
{
if(button3.Text==button6.Text &&
button3.Text==button9.Text)
{
button3.BackColor=Color.Green;
button3.ForeColor=Color.White;
button6.BackColor=Color.Green;
button6.ForeColor=Color.White;
button9.BackColor=Color.Green;
button9.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button3.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button3.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
if(button3.Text!=""
&& button5.Text!=""
&& button7.Text!="")
{
if(button3.Text==button5.Text &&
button3.Text==button7.Text)
{
button3.BackColor=Color.Green;
button3.ForeColor=Color.White;
button5.BackColor=Color.Green;
button5.ForeColor=Color.White;
button7.BackColor=Color.Green;
button7.ForeColor=Color.White;
if(twoPlayer.Checked == true)
{
if(button3.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Player
2 Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
else if(vsCom.Checked
== true)
{
if(button3.Text=="X")
{
MessageBox.Show("Player
1 Wins!");
player1++;
P1score.Text=player1.ToString();
}
else
{
MessageBox.Show("Computer
Wins!");
player2++;
P2score.Text=player2.ToString();
}
}
cleargame();
}
}
}
public void
cleargame()
{
disTurn.Text="";
turn=1;
click1=0;click2=0;click3=0;click4=0;click5=0;click6=0;click7=0;click8=0;click9=0;
button1.Text="";
button2.Text="";
button3.Text="";
button4.Text="";
button5.Text="";
button6.Text="";
button7.Text="";
button8.Text="";
button9.Text="";
button1.BackColor=Color.Empty;
button1.ForeColor=Color.Black;
button1.UseVisualStyleBackColor=true;
button2.BackColor=Color.Empty;
button2.ForeColor=Color.Black;
button2.UseVisualStyleBackColor=true;
button3.BackColor=Color.Empty;
button3.ForeColor=Color.Black;
button3.UseVisualStyleBackColor=true;
button4.BackColor=Color.Empty;
button4.ForeColor=Color.Black;
button4.UseVisualStyleBackColor=true;
button5.BackColor=Color.Empty;
button5.ForeColor=Color.Black;
button5.UseVisualStyleBackColor=true;
button6.BackColor=Color.Empty;
button6.ForeColor=Color.Black;
button6.UseVisualStyleBackColor=true;
button7.BackColor=Color.Empty;
button7.ForeColor=Color.Black;
button7.UseVisualStyleBackColor=true;
button8.BackColor=Color.Empty;
button8.ForeColor=Color.Black;
button8.UseVisualStyleBackColor=true;
button9.BackColor=Color.Empty;
button9.ForeColor=Color.Black;
button9.UseVisualStyleBackColor=true;
}
void Button1Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click1==0)
{
if(turn%2!=0)
{
button1.Text="X";
}
else
{
button1.Text="O";
}
turn++;
click1++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button1);
}
else
{
MessageBox.Show("silahkan pilih
game mode!!!");
}
display();
checkit();
}
void Button2Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click2==0)
{
if(turn%2!=0)
{
button2.Text="X";
}
else
{
button2.Text="O";
}
turn++;
click2++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button2);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button3Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click3==0)
{
if(turn%2!=0)
{
button3.Text="X";
}
else
{
button3.Text="O";
}
turn++;
click3++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button3);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button4Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click4==0)
{
if(turn%2!=0)
{
button4.Text="X";
}
else
{
button4.Text="O";
}
turn++;
click4++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref
button4);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button6Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click6==0)
{
if(turn%2!=0)
{
button6.Text="X";
}
else
{
button6.Text="O";
}
turn++;
click6++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button6);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button5Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click5==0)
{
if(turn%2!=0)
{
button5.Text="X";
}
else
{
button5.Text="O";
}
turn++;
click5++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button5);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button7Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click7==0)
{
if(turn%2!=0)
{
button7.Text="X";
}
else
{
button7.Text="O";
}
turn++;
click7++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button7);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button8Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click8==0)
{
if(turn%2!=0)
{
button8.Text="X";
}
else
{
button8.Text="O";
}
turn++;
click8++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button8);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button9Click(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
if(click9==0)
{
if(turn%2!=0)
{
button9.Text="X";
}
else
{
button9.Text="O";
}
turn++;
click9++;
}
else
{
MessageBox.Show("The
button is already chosen!!!");
}
}
else if(vsCom.Checked
== true)
{
ButtonClick(ref button9);
}
else
{
MessageBox.Show("Please chose game mode!!!");
}
display();
checkit();
}
void Button10Click(object
sender, EventArgs e)
{
cleargame();
}
void Button11Click(object
sender, EventArgs e)
{
P1score.Text="";
P2score.Text="";
player1=0;
player2=0;
cleargame();
}
void VsComCheckedChanged(object
sender, EventArgs e)
{
if(vsCom.Checked == true)
{
label3.Text="P1";
label4.Text="COM";
P1score.Text="";
P2score.Text="";
player1=0;
player2=0;
cleargame();
}
}
void TwoPlayerCheckedChanged(object
sender, EventArgs e)
{
if(twoPlayer.Checked == true)
{
label3.Text="P1";
label4.Text="P2";
P1score.Text="";
P2score.Text="";
player1=0;
player2=0;
cleargame();
}
}
private void
ButtonClick(ref Button
theButton)
{
if (vsCom.Checked)
{
if (theButton.Text == "")
{
theButton.Text = "X";
ComPlay();
checkit();
}
else
{
MessageBox.Show("The button is already chosen!!!");
}
}
}
private void
panel1_Paint(object sender, PaintEventArgs e)
{
}
}
}
TAMPILAN
PRMOGRAMAN
Comments
Post a Comment