日期:2014-05-17  浏览次数:20913 次

C#如何使图片进行随机循环 代码求解


实现出现一个之后,随机出现另一个
代码如下:
如何进行改修:
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;

namespace The_Name
{
    public partial class FormGame : Form
    {
      
        public FormGame()
        {
            InitializeComponent();
        }

        int shu;
   
        private void buttonKaiShi_Click(object sender, EventArgs e)
        {
           
            shu = SuiJi();
            timer1.Start();
            
        }

        public int SuiJi()
        {
            int sui = 0;
            Random random = new Random();
            sui = random.Next(1,8);
            return sui;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {


            switch (shu)
            {
                case 1:
                    pictureBox1.Top += 1;
                    if ( pictureBox1.Top >= pldi.Height)
                    {
                        pictureBox1.Top = pldi.Top;
                    }
                    
                    break;
                case 2:
                    pictureBox2.