close

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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
int d1, d2, d3, a2, c1, c2;
int a1 = 1;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Random ran = new Random();
d1 = ran.Next() % 6 + 1;
d2 = ran.Next() % 6 + 1;
a2 = a1 % 2;
label1.Text = Convert.ToString(d1);
label2.Text = Convert.ToString(d2);
d3 = d1 + d2;
textBox1.Text = Convert.ToString(d3);

for (int i = 1; i <= d1 + d2; i++)
{
Thread.Sleep(10);
Application.DoEvents();

if (a2 == 0)
button2.Location = new Point((c1 + i) * 5, 70);
else
button3.Location = new Point((c2 + i) * 5, 140);
}
if (a2 > 0)
c1 = c1 + d3;
else
c2 = c2 + d3;
a1 = a1 + 1;
if (c1 >= 25)
MessageBox.Show("P1 WIN!");
else if (c2 >= 25)
MessageBox.Show("P2 WIN!");
}

private void button2_Click(object sender, EventArgs e)
{

}
}
}

賽車  

arrow
arrow
    全站熱搜

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