=======================================================================
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 label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int d1, d2, dsum;
Random ir = new Random();
d1 = ir.Next(1, 7);
d2 = ir.Next(1, 7);
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
dsum = d1 + d2;
for (int i = 1; i <= dsum; i++)
{
button2.Left = i + ssum1;
Thread.Sleep(100); //Delay 1秒
Application.DoEvents();
}
textBox1.Text = Convert.ToString(ssum1);
ssum1 = ssum1 + dsum;
if (button2.Left >= 100)
{
MessageBox.Show ("馬1獲勝");
}
}
private void button4_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
int d1, d2, dsum;
Random ir = new Random();
d1 = ir.Next(1, 7);
d2 = ir.Next(1, 7);
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
dsum = d1 + d2;
for (int i = 1; i <= dsum; i++)
{
button4.Left = i + ssum2;
Thread.Sleep(100); //Delay 1秒
Application.DoEvents();
}
textBox1.Text = Convert.ToString(ssum2);
ssum2 = ssum2 + dsum;
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
沒有留言:
張貼留言