[[[ SALAM ]]]
Salam hangat para blogger sekalian ! :)
Pada kesempatan kali ini saya aan menunjukkan sebuah program yang tidak biasa seperti sebelum nya,kali ini saya akan menunjukkan sebuah program Game sederhana yang bernama Tic Tac Toe,sebelum kita ke progam nya saya akan menjelaskan apa itu Tic Tac Toe...
1. Tentang Tic Tac Toe dan Sejarah nya
APA SIH TIC TAC TOE.?
SEJARAH
Menurut sejarah Tic Tac Toe berasal dari Kekaisaran Romawi sekitar abad pertama sebelum masehi. Masyarakat setempat menyebutnya Terni Lapili. Permainan ini sama seperti yang kita temukan di zaman sekarang yang dimainkan oleh dua orang pemain dengan menggunakan tiga bidak, pemain harus membentuk satu barisan dengan bidak-bidak yang dimiiki di lembar kertas papirus. Namun ada informasi lain, menurut Claudia Zaslavsky dalam buku Tic Tac Toe: And Other Three-In-A Row Games from Ancient Egypt to the Modern Computer, Tic-Tac-Toe berasal dari Mesir kuno. Namun bagaimana permainan ini mulai disebut dengan nama Tic Tac Toe? Pada tahun 1884, anak-anak bermain di sebuah batu tulis dimana mereka menutup mata sambil mencoretkan batu dengan dua simbol "X" dan "O" membentuk satu barisan namun disertai suara tic dan tac dari anak-anak. Pada tahun 1952, Tic Tac Toe mulai marak diminati karena untuk pertama masuk ke dunia video game OXO (or Noughts and Crosses) untuk komputer EDSAC. Pemain bisa memainkan Tic-Tac-Toe dengan melawan komputer bahkan dapat multyplay melawan manusia. Pada tahun 1975, Tic Tac Toe juga digunakan oleh siswa MIT untuk menunjukkan kekuatan komputasi dari elemen Tinkertoy yang saat ini dipamerkan di Museum of Science, Boston .
.
.
.
Program Tic Tac Toe dengan C#
Oke,mungkin itu saja sekilas mengenai Tic Tac Toe,sekarang kita akan beralih ke program,tapi kita lihat dulu teori dasar nya...
Teori Dasar
Control PictureBox digunakan untuk menampilkan gambar dan memanipulasinya. PictureBox dapat menangani berbagai macam format file gambar. Dalam praktikum ini kita menggunakan PNG. Untuk mengisi PictureBox dengan gambar, kita tinggal load gambarnya dengan menge-klik Properties Image-nya. Kemudian sesuaikan ukuran Width dan Height nya sehingga gambar tidak terpotong.
Baiklah ,sekarang saya akan menunjukkan bagaimana program yang saya buat
Dapat dilihat jika form program saya terdiri dari
- 5 buah label
- 2 buah groupbox
- 2 buah button
- 9 buah pircture box
- 1 buah menu toolstrip(diatas form program)
Dan yang dibutuhkan adalah:
- Komputer/Laptop
- Kemauan
- Visual Studio / C Sharp Develop
1.Buka Visual Studio / C Sharp Develop
2.Seperti biasa,pilih WindowsFormApplication
3. ketika WindowsFormApllication yang akan kita edit sudah muncul,maka isilah form yang kosong dengan benda benda dari toolbox,semau anda yang penting disitu tersedia 9 picture box sebagai wadah menaruh gambar
4.Kita harus memberi event klik pada tiap picture box,pada menu event pilih Click
5.Baiklah,dan mari kira lihat seluruh kodingan nya
============================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication18
{
public partial class Form1 : Form
{
int start = 0;
int d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0, d7 = 0, d8 = 0, d9 = 0;
int type;
int kolor;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
// menaruh gambar pada picturebox dengan fungsi resources
void difficult(int type)
{
if (type == 5)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 1;
}
}
else if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d4 == 0)
{
if (start == 1)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d7 == 0 && d3 == 1 && d5 == 1)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 1)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
}
}
if (type == 2)
{
if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
}
if (type == 3)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
}
else if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 4)
{
if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
}
if (type == 6)
{
if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
else if (d4 == 0)
{
if (start == 1)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
}
if (type == 7)
{
if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d4 == 0)
{
if (start == 1)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 8)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 9)
{
if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
}
}
//pemilihan pihak
private void pictureBox1_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!"); // indikator jika pemain mengklik pictureBox jika belum memilih
}
else if (start > 0 && d1 == 0)
{
if (start % 2 == 0)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
type = 1;
difficult(1);
}
Win();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d2 == 0)
{
if (start % 2 == 0)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
type = 2;
difficult(2);
}
Win();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d3 == 0)
{
if (start % 2 == 0)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
type = 3;
difficult(3);
}
Win();
}
private void pictureBox4_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d4 == 0)
{
if (start % 2 == 0)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
type = 4;
difficult(4);
}
Win();
}
private void pictureBox5_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side first!");
}
else if (start > 0 && d5 == 0)
{
if (start % 2 == 0)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
type = 5;
difficult(5);
}
Win();
}
private void pictureBox6_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d6 == 0)
{
if (start % 2 == 0)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 1;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
type = 6;
difficult(6);
}
Win();
}
private void pictureBox7_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d7 == 0)
{
if (start % 2 == 0)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
type = 7;
difficult(7);
}
Win();
}
private void pictureBox8_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d8 == 0)
{
if (start % 2 == 0)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
type = 8;
difficult(8);
}
Win();
}
private void pictureBox9_Click(object sender, EventArgs e)
{
k
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d9 == 0)
{
if (start % 2 == 0)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
type = 9;
difficult(9);
}
Win();
}
//pemilihan pihak
//if you O
private void button3_Click(object sender, EventArgs e)
{
if (start == 0)
{
start = 1;
}
label4.Text = "you (O) vs Computer (X)";
}
//if you X
private void button4_Click(object sender, EventArgs e)
{
if (start == 0)
{
start = 2;
}
label4.Text = "you (X) vs Computer (O)";
}
void Win() //pemilihan pihak menang
{
//1 ,2 ,3
if (d1 == 2 && d2 == 2 && d3 == 2)
{
label5.Text = "X side win!";
}
else if (d1 == 1 && d2 == 1 && d3 == 1)
{
label5.Text = "O side win!";
}
//4, 5, 6
else if (d4 == 2 && d5 == 2 && d6 == 2)
{
label5.Text = "O side win!";
}
else if (d4 == 1 && d5 == 1 && d6 == 1)
{
label5.Text = "X side win!";
}
//win 7 , 8 , 9
else if (d7 == 2 && d8 == 2 && d9 == 2)
{
label5.Text = "X side win!";
}
else if (d7 == 1 && d8 == 1 && d9 == 1)
{
label5.Text = "O side win!";
}
//1, 4 ,7
else if (d1 == 2 && d4 == 2 && d7 == 2)
{
label5.Text = "X side win!";
}
else if (d1 == 1 && d4 == 1 && d7 == 1)
{
label5.Text = "O side win!";
}
//2, 5, 8
else if (d2 == 2 && d5 == 2 && d8 == 2)
{
label5.Text = "X side win!";
}
else if (d2 == 1 && d5 == 1 && d8 == 1)
{
label5.Text = "O side win!";
}
//3, 6 , 9
else if (d3 == 2 && d6 == 2 && d9 == 2)
{
label5.Text = "X side win!";
}
else if (d3 == 1 && d6 == 1 && d9 == 1)
{
label5.Text = "O side win!";
}
//diagonal
//1, 5 , 9
else if (d1 == 2 && d5 == 2 && d9 == 2)
{
label5.Text = "X side win!";
}
else if (d1 == 1 && d5 == 1 && d9 == 1)
{
label5.Text = "O side win!";
}
//3, 5 , 7
else if (d3 == 2 && d5 == 2 && d7 == 2)
{
label5.Text = "X side win!";
}
else if (d3 == 1 && d5 == 1 && d7 == 1)
{
label5.Text = "O side win!";
}
}
private void button_Click(object sender, EventArgs e)
{
}
private void Picture_Click(object sender, EventArgs e)
{
}
private void exit()
{ //message box exit
DialogResult result = MessageBox.Show("Really?", "Hold up for a sec'", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes) this.Close();
}
private void Exit_click(object sender, EventArgs e)
{ //memanggil void exit()
exit();
}
private void newgame_click(object sender, EventArgs e)
{ //reset semua
pictureBox1.BackgroundImage = null;
pictureBox2.BackgroundImage = null;
pictureBox3.BackgroundImage = null;
pictureBox4.BackgroundImage = null;
pictureBox5.BackgroundImage = null;
pictureBox6.BackgroundImage = null;
pictureBox7.BackgroundImage = null;
pictureBox8.BackgroundImage = null;
pictureBox9.BackgroundImage = null;
d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = d9 = 0;
label4.Text = "";
label1.Text = "";
start = 0;
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication18
{
public partial class Form1 : Form
{
int start = 0;
int d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0, d7 = 0, d8 = 0, d9 = 0;
int type;
int kolor;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
// menaruh gambar pada picturebox dengan fungsi resources
void difficult(int type)
{
if (type == 5)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 1;
}
}
else if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d4 == 0)
{
if (start == 1)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d7 == 0 && d3 == 1 && d5 == 1)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 1)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
}
}
if (type == 2)
{
if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
}
if (type == 3)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
}
else if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 4)
{
if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
}
if (type == 6)
{
if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
else if (d4 == 0)
{
if (start == 1)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
}
if (type == 7)
{
if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d4 == 0)
{
if (start == 1)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 8)
{
if (d2 == 0)
{
if (start == 1)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d9 == 0)
{
if (start == 1)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
}
}
if (type == 9)
{
if (d1 == 0)
{
if (start == 1)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
}
else if (d3 == 0)
{
if (start == 1)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
}
else if (d6 == 0)
{
if (start == 1)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 2;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
}
else if (d7 == 0)
{
if (start == 1)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
}
else if (d8 == 0)
{
if (start == 1)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
}
else if (d5 == 0)
{
if (start == 1)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
}
}
}
//pemilihan pihak
private void pictureBox1_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!"); // indikator jika pemain mengklik pictureBox jika belum memilih
}
else if (start > 0 && d1 == 0)
{
if (start % 2 == 0)
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d1 = 2;
}
else
{
pictureBox1.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d1 = 1;
}
type = 1;
difficult(1);
}
Win();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d2 == 0)
{
if (start % 2 == 0)
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d2 = 2;
}
else
{
pictureBox2.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d2 = 1;
}
type = 2;
difficult(2);
}
Win();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d3 == 0)
{
if (start % 2 == 0)
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d3 = 2;
}
else
{
pictureBox3.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d3 = 1;
}
type = 3;
difficult(3);
}
Win();
}
private void pictureBox4_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d4 == 0)
{
if (start % 2 == 0)
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d4 = 2;
}
else
{
pictureBox4.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d4 = 1;
}
type = 4;
difficult(4);
}
Win();
}
private void pictureBox5_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side first!");
}
else if (start > 0 && d5 == 0)
{
if (start % 2 == 0)
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d5 = 2;
}
else
{
pictureBox5.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d5 = 1;
}
type = 5;
difficult(5);
}
Win();
}
private void pictureBox6_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d6 == 0)
{
if (start % 2 == 0)
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d6 = 1;
}
else
{
pictureBox6.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d6 = 1;
}
type = 6;
difficult(6);
}
Win();
}
private void pictureBox7_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d7 == 0)
{
if (start % 2 == 0)
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d7 = 2;
}
else
{
pictureBox7.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d7 = 1;
}
type = 7;
difficult(7);
}
Win();
}
private void pictureBox8_Click(object sender, EventArgs e)
{
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d8 == 0)
{
if (start % 2 == 0)
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d8 = 2;
}
else
{
pictureBox8.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d8 = 1;
}
type = 8;
difficult(8);
}
Win();
}
private void pictureBox9_Click(object sender, EventArgs e)
{
k
if (start == 0)
{
MessageBox.Show("Choose Your Side!");
}
else if (start > 0 && d9 == 0)
{
if (start % 2 == 0)
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.x;
d9 = 2;
}
else
{
pictureBox9.BackgroundImage = WindowsFormsApplication18.Properties.Resources.o;
d9 = 1;
}
type = 9;
difficult(9);
}
Win();
}
//pemilihan pihak
//if you O
private void button3_Click(object sender, EventArgs e)
{
if (start == 0)
{
start = 1;
}
label4.Text = "you (O) vs Computer (X)";
}
//if you X
private void button4_Click(object sender, EventArgs e)
{
if (start == 0)
{
start = 2;
}
label4.Text = "you (X) vs Computer (O)";
}
void Win() //pemilihan pihak menang
{
//1 ,2 ,3
if (d1 == 2 && d2 == 2 && d3 == 2)
{
label5.Text = "X side win!";
}
else if (d1 == 1 && d2 == 1 && d3 == 1)
{
label5.Text = "O side win!";
}
//4, 5, 6
else if (d4 == 2 && d5 == 2 && d6 == 2)
{
label5.Text = "O side win!";
}
else if (d4 == 1 && d5 == 1 && d6 == 1)
{
label5.Text = "X side win!";
}
//win 7 , 8 , 9
else if (d7 == 2 && d8 == 2 && d9 == 2)
{
label5.Text = "X side win!";
}
else if (d7 == 1 && d8 == 1 && d9 == 1)
{
label5.Text = "O side win!";
}
//1, 4 ,7
else if (d1 == 2 && d4 == 2 && d7 == 2)
{
label5.Text = "X side win!";
}
else if (d1 == 1 && d4 == 1 && d7 == 1)
{
label5.Text = "O side win!";
}
//2, 5, 8
else if (d2 == 2 && d5 == 2 && d8 == 2)
{
label5.Text = "X side win!";
}
else if (d2 == 1 && d5 == 1 && d8 == 1)
{
label5.Text = "O side win!";
}
//3, 6 , 9
else if (d3 == 2 && d6 == 2 && d9 == 2)
{
label5.Text = "X side win!";
}
else if (d3 == 1 && d6 == 1 && d9 == 1)
{
label5.Text = "O side win!";
}
//diagonal
//1, 5 , 9
else if (d1 == 2 && d5 == 2 && d9 == 2)
{
label5.Text = "X side win!";
}
else if (d1 == 1 && d5 == 1 && d9 == 1)
{
label5.Text = "O side win!";
}
//3, 5 , 7
else if (d3 == 2 && d5 == 2 && d7 == 2)
{
label5.Text = "X side win!";
}
else if (d3 == 1 && d5 == 1 && d7 == 1)
{
label5.Text = "O side win!";
}
}
private void button_Click(object sender, EventArgs e)
{
}
private void Picture_Click(object sender, EventArgs e)
{
}
private void exit()
{ //message box exit
DialogResult result = MessageBox.Show("Really?", "Hold up for a sec'", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes) this.Close();
}
private void Exit_click(object sender, EventArgs e)
{ //memanggil void exit()
exit();
}
private void newgame_click(object sender, EventArgs e)
{ //reset semua
pictureBox1.BackgroundImage = null;
pictureBox2.BackgroundImage = null;
pictureBox3.BackgroundImage = null;
pictureBox4.BackgroundImage = null;
pictureBox5.BackgroundImage = null;
pictureBox6.BackgroundImage = null;
pictureBox7.BackgroundImage = null;
pictureBox8.BackgroundImage = null;
pictureBox9.BackgroundImage = null;
d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = d9 = 0;
label4.Text = "";
label1.Text = "";
start = 0;
}
dan ini adalah kodingan tambahan (sambungan dari atas)
private void howToPlayToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("kalahkan lawan dengan mengisi 3 buah kotak secara berurut \n \n 1.pilih simbol apa pihak kamu X atau O? \n \n 2.isi kotak yang berwarna merah secara ber-urutan vertical,horizontal,atau diagonal \n \n 3.jangan biarkan lawan mengalahkan mu! \n \n 4.HAVE FUN!! :)", "Read This");
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("TicTacToe v 1.0.0 \n \n \n Dibuat dengan penuh kesabaran,dengan compile sana sini,ngoding sana sini,tapi puji Tuhan bisa juga akhirnya :) \n \n By: Imanuel Simatupang \n \n \n Copyright 2015", "Info");
}
private void timer1_Tick(object sender, EventArgs e)
{
kolor = kolor + 1;
switch (kolor)
{
case 0: label1.ForeColor = Color.White; break;
case 1: label1.ForeColor = Color.WhiteSmoke; break;
case 2: label1.ForeColor = Color.Gainsboro; break;
case 3: label1.ForeColor = Color.LightGray; break; //tulisan Tic
case 4: label1.ForeColor = Color.Silver; break;
case 5: label1.ForeColor = Color.DarkGray; break;
case 6: label1.ForeColor = Color.Gray; break;
case 7: label1.ForeColor = Color.DimGray; break;
case 8: label1.ForeColor = Color.Black; break;
case 9: label1.ForeColor = Color.Black; break;
case 10: label1.ForeColor = Color.DimGray; break;
case 11: label1.ForeColor = Color.Gray; break;
case 12: label1.ForeColor = Color.DarkGray; break;
case 13: label1.ForeColor = Color.Silver; break;
case 14: label1.ForeColor = Color.LightGray; break;
case 15: label1.ForeColor = Color.Gainsboro; break;
case 16: label1.ForeColor = Color.WhiteSmoke; break;
case 17: label1.ForeColor = Color.White; break;
}
if (kolor > 16)
{ kolor = 0; }
}
private void timer2_Tick(object sender, EventArgs e)
{
kolor = kolor + 1;
switch (kolor)
{
case 0: label2.ForeColor = Color.White; break;
case 1: label2.ForeColor = Color.WhiteSmoke; break;
case 2: label2.ForeColor = Color.Gainsboro; break;
case 3: label2.ForeColor = Color.LightGray; break;
case 4: label2.ForeColor = Color.Silver; break;
case 5: label2.ForeColor = Color.DarkGray; break; //tulisan Tac
case 6: label2.ForeColor = Color.Gray; break;
case 7: label2.ForeColor = Color.DimGray; break;
case 8: label2.ForeColor = Color.Black; break;
case 9: label2.ForeColor = Color.Black; break;
case 10: label2.ForeColor = Color.DimGray; break;
case 11: label2.ForeColor = Color.Gray; break;
case 12: label2.ForeColor = Color.DarkGray; break;
case 13: label2.ForeColor = Color.Silver; break;
case 14: label2.ForeColor = Color.LightGray; break;
case 15: label2.ForeColor = Color.Gainsboro; break;
case 16: label2.ForeColor = Color.WhiteSmoke; break;
case 17: label2.ForeColor = Color.White; break;
}
if (kolor > 16)
{ kolor = 0; }
}
private void timer3_Tick(object sender, EventArgs e)
{
kolor = kolor + 1;
switch (kolor)
{
case 0: label3.ForeColor = Color.White; break;
case 1: label3.ForeColor = Color.WhiteSmoke; break;
case 2: label3.ForeColor = Color.Gainsboro; break;
case 3: label3.ForeColor = Color.LightGray; break;
case 4: label3.ForeColor = Color.Silver; break;
case 5: label3.ForeColor = Color.DarkGray; break;
case 6: label3.ForeColor = Color.Gray; break;
case 7: label3.ForeColor = Color.DimGray; break; //tulisan Toe
case 8: label3.ForeColor = Color.Black; break;
case 9: label3.ForeColor = Color.Black; break;
case 10: label3.ForeColor = Color.DimGray; break;
case 11: label3.ForeColor = Color.Gray; break;
case 12: label3.ForeColor = Color.DarkGray; break;
case 13: label3.ForeColor = Color.Silver; break;
case 14: label3.ForeColor = Color.LightGray; break;
case 15: label3.ForeColor = Color.Gainsboro; break;
case 16: label3.ForeColor = Color.WhiteSmoke; break;
case 17: label3.ForeColor = Color.White; break;
}
if (kolor > 16)
{ kolor = 0; }
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
}
}
{
MessageBox.Show("kalahkan lawan dengan mengisi 3 buah kotak secara berurut \n \n 1.pilih simbol apa pihak kamu X atau O? \n \n 2.isi kotak yang berwarna merah secara ber-urutan vertical,horizontal,atau diagonal \n \n 3.jangan biarkan lawan mengalahkan mu! \n \n 4.HAVE FUN!! :)", "Read This");
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("TicTacToe v 1.0.0 \n \n \n Dibuat dengan penuh kesabaran,dengan compile sana sini,ngoding sana sini,tapi puji Tuhan bisa juga akhirnya :) \n \n By: Imanuel Simatupang \n \n \n Copyright 2015", "Info");
}
private void timer1_Tick(object sender, EventArgs e)
{
kolor = kolor + 1;
switch (kolor)
{
case 0: label1.ForeColor = Color.White; break;
case 1: label1.ForeColor = Color.WhiteSmoke; break;
case 2: label1.ForeColor = Color.Gainsboro; break;
case 3: label1.ForeColor = Color.LightGray; break; //tulisan Tic
case 4: label1.ForeColor = Color.Silver; break;
case 5: label1.ForeColor = Color.DarkGray; break;
case 6: label1.ForeColor = Color.Gray; break;
case 7: label1.ForeColor = Color.DimGray; break;
case 8: label1.ForeColor = Color.Black; break;
case 9: label1.ForeColor = Color.Black; break;
case 10: label1.ForeColor = Color.DimGray; break;
case 11: label1.ForeColor = Color.Gray; break;
case 12: label1.ForeColor = Color.DarkGray; break;
case 13: label1.ForeColor = Color.Silver; break;
case 14: label1.ForeColor = Color.LightGray; break;
case 15: label1.ForeColor = Color.Gainsboro; break;
case 16: label1.ForeColor = Color.WhiteSmoke; break;
case 17: label1.ForeColor = Color.White; break;
}
if (kolor > 16)
{ kolor = 0; }
}
private void timer2_Tick(object sender, EventArgs e)
{
kolor = kolor + 1;
switch (kolor)
{
case 0: label2.ForeColor = Color.White; break;
case 1: label2.ForeColor = Color.WhiteSmoke; break;
case 2: label2.ForeColor = Color.Gainsboro; break;
case 3: label2.ForeColor = Color.LightGray; break;
case 4: label2.ForeColor = Color.Silver; break;
case 5: label2.ForeColor = Color.DarkGray; break; //tulisan Tac
case 6: label2.ForeColor = Color.Gray; break;
case 7: label2.ForeColor = Color.DimGray; break;
case 8: label2.ForeColor = Color.Black; break;
case 9: label2.ForeColor = Color.Black; break;
case 10: label2.ForeColor = Color.DimGray; break;
case 11: label2.ForeColor = Color.Gray; break;
case 12: label2.ForeColor = Color.DarkGray; break;
case 13: label2.ForeColor = Color.Silver; break;
case 14: label2.ForeColor = Color.LightGray; break;
case 15: label2.ForeColor = Color.Gainsboro; break;
case 16: label2.ForeColor = Color.WhiteSmoke; break;
case 17: label2.ForeColor = Color.White; break;
}
if (kolor > 16)
{ kolor = 0; }
}
private void timer3_Tick(object sender, EventArgs e)
{
kolor = kolor + 1;
switch (kolor)
{
case 0: label3.ForeColor = Color.White; break;
case 1: label3.ForeColor = Color.WhiteSmoke; break;
case 2: label3.ForeColor = Color.Gainsboro; break;
case 3: label3.ForeColor = Color.LightGray; break;
case 4: label3.ForeColor = Color.Silver; break;
case 5: label3.ForeColor = Color.DarkGray; break;
case 6: label3.ForeColor = Color.Gray; break;
case 7: label3.ForeColor = Color.DimGray; break; //tulisan Toe
case 8: label3.ForeColor = Color.Black; break;
case 9: label3.ForeColor = Color.Black; break;
case 10: label3.ForeColor = Color.DimGray; break;
case 11: label3.ForeColor = Color.Gray; break;
case 12: label3.ForeColor = Color.DarkGray; break;
case 13: label3.ForeColor = Color.Silver; break;
case 14: label3.ForeColor = Color.LightGray; break;
case 15: label3.ForeColor = Color.Gainsboro; break;
case 16: label3.ForeColor = Color.WhiteSmoke; break;
case 17: label3.ForeColor = Color.White; break;
}
if (kolor > 16)
{ kolor = 0; }
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
}
}
Dan ini Videonya
Baiklah,mungkin sekia dari saya,maaf jika ada yang tak jelas,dan kesalahan penulisan kata
Terima Kasih :)
---SALAM KOMPAK!!!---
Tidak ada komentar:
Posting Komentar