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

private void button2_Click(object sender, EventArgs e)
{
int d1;
int 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 (int i=0;i <=d1+d2;i++)
{

Thread.Sleep(500); //Delay 0.5秒
Application.DoEvents();

button1.Left = button1.Left + i*5;

}
if (button1.Left >= 300)
MessageBox.Show("甲贏");

}


private void label1_Click(object sender, EventArgs e)
{

}

private void button4_Click(object sender, EventArgs e)
{
int d1;
int 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 (int i = 0; i <= d1 + d2; i++)
{

Thread.Sleep(500); //Delay 0.5秒
Application.DoEvents();

button3.Left = button3.Left + i * 5;


}
if (button3.Left >= 300)
MessageBox.Show("乙贏");

}

}
}

 

未命名2  

 

 

更新

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 sum2=0;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
int d1;
int d2;
int sum1;



Random ran = new Random();
d1 = ran.Next(1, 7);
d2 = ran.Next(1, 7);

label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);

 

sum1 = d1 + d2;


for (int i = 0; i <= sum1; i++)
{
button2.Left = i + sum2*10;
Thread.Sleep(100);
Application.DoEvents();

}

sum2 = sum2 + sum1;
textBox1.Text = Convert.ToString(sum2);
if (button2.Left >= 300)
MessageBox.Show("甲贏");
}

private void button3_Click(object sender, EventArgs e)
{
int d1;
int d2;
int sum1;

 

Random ran = new Random();
d1 = ran.Next(1, 7);
d2 = ran.Next(1, 7);

label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);

 

sum1 = d1 + d2;


for (int i = 0; i <= sum1; i++)
{
button4.Left = i+sum2*10;
Thread.Sleep(100);
Application.DoEvents();



}

sum2 = sum2 + sum1;
textBox1.Text = Convert.ToString(sum2);
if (button4.Left >= 300)
MessageBox.Show("乙贏");
}
}
}

 

arrow
arrow
    文章標籤
    跑馬
    全站熱搜

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