2014年12月4日 星期四

擲骰子大富翁----------------2014/10/17

目前最夯的手機遊戲-旅遊大亨
就是這個的延伸系統 放入一些道具卡、特殊地標
就能有類似效果


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 Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int d1, d2;
            Random ran = new Random();
            d1 = ran.Next(1, 7);
            d2 = ran.Next(1, 7);  //隨機從1~6中選取一數 就可以有擲骰子功能 
            label1.Text = Convert.ToString(d1);
            label2.Text = Convert.ToString(d2);
            for (int i = 1; i <= d1 + d2; i++)
            {

                Thread.Sleep(1000); //Delay 1秒  
                Application.DoEvents();
                button3.Left = 10 * i;   //此為設定物件移動速度
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int 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 (int i = 1; i <= (d1 + d2); i++)
            {
                button4.Left = 10 * i;
                Thread.Sleep(1000); //Delay 1秒
                Application.DoEvents();
              
            }
            }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
        }
    }
}

沒有留言:

張貼留言