1024  

 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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
int c = 0;
int r;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
button1.Text = "";
button2.Text = "";
button3.Text = "";
button4.Text = "";
button5.Text = "";
button6.Text = "";
button7.Text = "";
button8.Text = "";
button9.Text = "";
}

private void button1_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button1.Text = "O";
}
else if (r == 1)
{
button1.Text = "X";
}
button1.Enabled = false;
}

private void button2_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button2.Text = "O";
}
else if (r == 1)
{
button2.Text = "X";
}
button2.Enabled = false;
}

private void button3_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button3.Text = "O";
}
else if (r == 1)
{
button3.Text = "X";
}
button3.Enabled = false;
}

private void button4_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button4.Text = "O";
}
else if (r == 1)
{
button4.Text = "X";
}
button4.Enabled = false;
}

private void button5_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button5.Text = "O";
}
else if (r == 1)
{
button5.Text = "X";
}
button5.Enabled = false;
}

private void button6_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button6.Text = "O";
}
else if (r == 1)
{
button6.Text = "X";
}
button6.Enabled = false;
}

private void button7_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button7.Text = "O";
}
else if (r == 1)
{
button7.Text = "X";
}
button7.Enabled = false;
}

private void button8_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button8.Text = "O";
}
else if (r == 1)
{
button8.Text = "X";
}
button8.Enabled = false;
}

private void button9_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 2;
if (r == 0)
{
button9.Text = "O";
}
else if (r == 1)
{
button9.Text = "X";
}
button9.Enabled = false;
}
}
}

芫兒 發表在 痞客邦 留言(0) 人氣()

1024  

 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;
using System.Threading;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int ssum1 = 0;
int ssum2 = 0;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int d1, d2, dsum;
Random irand = new Random();
d1 = irand.Next(1, 7);
d2 = irand.Next(1, 7);
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
dsum = d1 + d2;
for (int i = 1; i <= dsum; i++)
{
Thread.Sleep(10);
button2.Left = i + ssum1;
Application.DoEvents();
}

ssum1 = ssum1 + dsum;
textBox1.Text = Convert.ToString(ssum1);
if (button2.Left >= 50)
MessageBox.Show("Player1 win.");

}

private void button3_Click(object sender, EventArgs e)
{
int d1, d2, dsum;
Random irand = new Random();
d1 = irand.Next(1, 7);
d2 = irand.Next(1, 7);
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
dsum = d1 + d2;
for (int i = 1; i <= dsum; i++)
{
Thread.Sleep(10);
button4.Left = i + ssum2;
Application.DoEvents();
}

ssum2 = ssum2 + dsum;
textBox1.Text = Convert.ToString(ssum2);
if (button4.Left >= 50)
MessageBox.Show("Player2 win.");
}

}
}

芫兒 發表在 痞客邦 留言(0) 人氣()

1017  

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;
using System.Threading;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
int d,c;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
int d1, d2,i;
Random ran = new Random();
d1 = ran.Next(1, 7);
d2 = ran.Next(1, 7);
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
for (i=1;i <= d1 + d2; i++)
{
Thread.Sleep(10);
button1.Left = d+i;
Application.DoEvents();
}
d=d+i;
if (button1.Left >= 20)
MessageBox.Show("Player1 win.");
}
private void button4_Click(object sender, EventArgs e)
{
int i,d1, d2;
Random ran = new Random();
d1 = ran.Next(1, 7);
d2 = ran.Next(1, 7);
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
for (i = 1; i <= d1 + d2; i++)
{
Thread.Sleep(10);
button3.Left = c+i;
Application.DoEvents();
}
c = c + i;
if (button3.Left >= 20)
MessageBox.Show("Player2 win.");
}
}
}

芫兒 發表在 痞客邦 留言(0) 人氣()

0926  

 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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
int c, r;

public Form1()
{
InitializeComponent();
c = 0;
}

private void button4_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 3;

if (r == 0)
{
button1.BackColor = Color.Red;
button2.BackColor = Color.White;
button3.BackColor = Color.White;
}
else if (r == 1)
{
button1.BackColor = Color.White;
button2.BackColor = Color.Yellow;
button3.BackColor = Color.White;
}
else
{
button1.BackColor = Color.White;
button2.BackColor = Color.White;
button3.BackColor = Color.Blue;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
r = c % 3;

if (r == 0)
{
button1.BackColor = Color.Red;
button2.BackColor = Color.White;
button3.BackColor = Color.White;
}
else if (r == 1)
{
button1.BackColor = Color.White;
button2.BackColor = Color.Yellow;
button3.BackColor = Color.White;
}
else
{
button1.BackColor = Color.White;
button2.BackColor = Color.White;
button3.BackColor = Color.Blue;
}
}
}
}

芫兒 發表在 痞客邦 留言(0) 人氣()

#C move object

using System;

芫兒 發表在 痞客邦 留言(0) 人氣()

«12