close

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.");
}
}
}

arrow
arrow
    全站熱搜

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