| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 768 人关注过本帖
标题:俄罗斯方块速度怎么搞,我设的速度都没有用,而且我把速度都删了方块还能运 ...
只看楼主 加入收藏
杰与贤3
Rank: 2
等 级:论坛游民
帖 子:11
专家分:18
注 册:2013-5-17
收藏
 问题点数:0 回复次数:2 
俄罗斯方块速度怎么搞,我设的速度都没有用,而且我把速度都删了方块还能运行
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace 俄罗斯方块
{
    public partial class Form1 : Form
    {
        Russia MyRussia = new Russia();
        Russia TemRussia = new Russia();//生成下一个方块样式
        public static int Crand = 0;//记录下一个方块样式的标识
        public static bool b = false;//判断是否生成下一个方块的样式
        public static bool isbegin = false;//判断当前游戏是否开始
        public bool stop = true;//判断是否暂停游戏
        public Timer timer = new Timer();
        public Form1()
        {
            InitializeComponent();
        }

        private void 结束游戏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 开始游戏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MyRussia.GameBackClear();
            MyRussia.firstcake = new Point(140, 20);
            MyRussia.hang = labhang;
            MyRussia.fenshu = labfenshu;
            timer1.Enabled = true;//开始计时
            if (Convert.ToInt32(labfenshu.Text) < 7)
            {
                timer1.Interval = 300;
            }
            else if (Convert.ToInt32(labfenshu.Text) > 7)
            {
                timer1.Interval = 30;
            }
            Random rand = new Random();
            Crand= rand.Next(1, 8);
            MyRussia.CakeMode(Crand);
            MyRussia.ProtractCake(panel1);
            nextcake();
            MyRussia.PlaceInitialization();
            isbegin = true;
            //stop = false;
            MyRussia.time = timer1;
            暂停游戏ToolStripMenuItem.Text = "暂停";
            stop = true;
            textBox1.Focus();//获取焦点
        }

        public void nextcake()//提示下个方块的方法
        {
            Graphics P3 = panel3.CreateGraphics();
            P3.FillRectangle(new SolidBrush(Color.Black), 0, 0, panel3.Width, panel3.Height);
            Random rand = new Random();
            Crand = rand.Next(1, 8);
            TemRussia.firstcake = new Point(50, 30);//设置方块的起始位置
            TemRussia.CakeMode(Crand);//设置方块的样式
            TemRussia.ProtractCake(panel3);//绘制组合方块
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (!isbegin)
                return;
            if (!stop)
                return;
            if (e.KeyCode == Keys.Up)//↑键
            { MyRussia.MyConvertorMode(); }
            if (e.KeyCode == Keys.Down)//↓键
            {
                timer1.Interval = 150;
                MyRussia.ConvertorMove(0);
            }
            if (e.KeyCode == Keys.Left)//←键
                MyRussia.ConvertorMove(1);
            if (e.KeyCode == Keys.Right)//→键
                MyRussia.ConvertorMove(2);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            MyRussia.ConvertorMove(0);//方块下移
            if (b)
            {
                nextcake();//生成下一个方块
                b = false;
            }
            textBox1.Focus();//获取焦点
        }

        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (!isbegin)
                return;
            if (!stop)
                return;
            if (e.KeyCode == Keys.Down)
            {
                timer1.Interval = 200;
            }
            textBox1.Focus();//获取焦点
        }

        private void 暂停游戏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (timer1.Enabled == true)
            {
                timer1.Stop();//暂停
                暂停游戏ToolStripMenuItem.Text = "继续";
                stop = false;
                textBox1.Focus();//获取焦点
            }
            else
            {
                timer1.Start();//继续
                暂停游戏ToolStripMenuItem.Text = "暂停";
                stop = true;
                textBox1.Focus();//获取焦点

            }
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            if (isbegin)
            {
                for (int i = 0; i <= (panel1.Width / 20 - 1); i++)
                {
                    for (int j = 0; j <= (panel1.Height / 20 - 1); j++)
                    {
                        Rectangle rect = new Rectangle(i * 20 + 1, j * 20 + 1, 19, 19);//获取各方块的绘制区域
                        e.Graphics.FillRectangle(new SolidBrush(Russia.PlaceColor[i, j]), rect);
                    }
                }
            }
        }

        private void panel3_Paint(object sender, PaintEventArgs e)
        {
            if (isbegin)
            {
                TemRussia.firstcake = new Point(50, 30);
                TemRussia.CakeMode(Crand);//设置方块的样式
                TemRussia.ProtractCake(panel3);//绘制组合方块
            }
        }



      
    }
}













using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace 俄罗斯方块
{
    public class Russia
    {
        public Point firstcake = new Point(140, 20);//定义方块的起始位置
        public static Color[,] PlaceColor;
        public static bool[,] Place;//方块位置
        public static int conWidth = 0;//记录列数
        public static int conHeight = 0;//记录行数
        public static int maxY = 0;//方块在行中的最小高度
        public static int conMax = 0;//方块落下后的最大位置
        public static int conMin = 0;//方块落下后的最小位置
        Point[] ArryPoi = new Point[4];//方块的数组
        Point[] Arryfront = new Point[4];//前一个方块的数组
        int Cake = 20;//定义方块的大小
        int Con = 0;//方块变换变量
        Control Mycontrol = new Control();
        public Timer time = new Timer();
        Color CakeColor;
        public int line;
        bool[] tem_Array = { false, false, false, false };//记录方块组中那一块所在行中已满
        public  Label hang = new Label();
        public Label fenshu = new Label();
        public static int[] ArrayCent = new int[] { 5, 7, 9 ,11};


        /// <summary>
        /// 设置方块的样式
        /// n是方块的样式
        /// </summary>
        public void CakeMode(int n)
        {
            ArryPoi[0] = firstcake;//记录方块的起始位置,即第一块
            switch (n)
            {
                case 1://“L”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X, firstcake.Y - Cake);//第二块方块的位置
                        ArryPoi[2] = new Point(firstcake.X, firstcake.Y + Cake);//第三块方块的位置
                        ArryPoi[3] = new Point(firstcake.X + Cake, firstcake.Y + Cake);//第四块方块的位置
                        CakeColor = Color.Yellow;
                        Con= 2;//方块变化
                        break;
                    }
                case 2://组合“Z”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X, firstcake.Y - Cake);
                        ArryPoi[2] = new Point(firstcake.X - Cake, firstcake.Y - Cake);
                        ArryPoi[3] = new Point(firstcake.X + Cake, firstcake.Y);
                        CakeColor = Color.Green;
                        Con = 6;
                        break;
                    }
               
               
                case 3://组合“T”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X, firstcake.Y - Cake);
                        ArryPoi[2] = new Point(firstcake.X + Cake, firstcake.Y - Cake);
                        ArryPoi[3] = new Point(firstcake.X - Cake, firstcake.Y - Cake);
                        CakeColor = Color.Silver;
                        Con = 8;
                        break;
                    }

                case 4://组合“一”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X + Cake, firstcake.Y);
                        ArryPoi[2] = new Point(firstcake.X - Cake, firstcake.Y);
                        ArryPoi[3] = new Point(firstcake.X - Cake * 2, firstcake.Y);
                        CakeColor = Color.Red;
                        Con = 12;
                        break;
                    }

                case 5://组合“田”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X - Cake, firstcake.Y);
                        ArryPoi[2] = new Point(firstcake.X - Cake, firstcake.Y - Cake);
                        ArryPoi[3] = new Point(firstcake.X, firstcake.Y - Cake);
                        CakeColor = Color.LightCoral;
                        Con = 13;
                        break;
                    }

                case 6://组合倒“L”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X, firstcake.Y - Cake);
                        ArryPoi[2] = new Point(firstcake.X, firstcake.Y + Cake);
                        ArryPoi[3] = new Point(firstcake.X - Cake, firstcake.Y + Cake);
                        CakeColor = Color.CornflowerBlue;
                        Con = 15;
                        break;
                    }
                case 7://组合倒“Z”方块
                    {
                        ArryPoi[1] = new Point(firstcake.X, firstcake.Y - Cake);
                        ArryPoi[2] = new Point(firstcake.X + Cake, firstcake.Y - Cake);
                        ArryPoi[3] = new Point(firstcake.X - Cake, firstcake.Y);
                        CakeColor = Color.Blue;
                        Con = 19;
                        break;
                    }
            }
        }

        /// <summary>
        /// 设置方块的变换样式
        /// n是判断变换的样式
        /// </summary>      
        public void ConvertorMode(int n)
        {
            Point[] temporaryArray = new Point[4];//定义一个数组用于记录当前方块
            Point cake_Poi = firstcake;//获取方块的起始位置
            int w = n;//记录方块的下一个变换样式

            for (int i = 0; i < temporaryArray.Length; i++)
                temporaryArray[i] = ArryPoi[i];
            switch (n)
            {
                case 1://设置“L”方块的起始样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        temporaryArray[3] = new Point(cake_Poi.X + Cake, cake_Poi.Y + Cake);
                        w = 2;//记录变换样式的标志
                        break;
                    }
                case 2://L样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X - Cake, cake_Poi.Y + Cake);
                        w = 3;
                        break;
                    }
                case 3://L样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        w = 4;
                        break;
                    }
                case 4://L样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X + Cake, cake_Poi.Y - Cake);
                        w = 1;//返回方块的起始样式
                        break;
                    }
                case 5://Z
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        w = 6;
                        break;
                    }
                case 6://Z样式,只有一种
                    {
                        temporaryArray[1] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        w = 5;
                        break;
                    }
               
                case 7://T
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X - Cake, cake_Poi.Y - Cake);
                        w = 8;
                        break;
                    }
                case 8://T样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        temporaryArray[3] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        w = 9;
                        break;
                    }
                case 9://T样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        w = 10;
                        break;
                    }
                case 10://T样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        w = 8;
                        break;
                    }
                case 11://一
                    {
                        temporaryArray[1] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X - Cake * 2, cake_Poi.Y);
                        w = 12;
                        break;
                    }
                case 12://一样式,只有一种
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y + Cake * 2);
                        w = 11;
                        break;
                    }
                case 13://田,无旋转
                    {
                        temporaryArray[1] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        w = 19;
                        break;
                    }
                case 14://倒L
                    {
                        temporaryArray[1] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X + Cake, cake_Poi.Y + Cake);
                        w = 15;
                        break;
                    }
                case 15://倒L样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        temporaryArray[3] = new Point(cake_Poi.X - Cake, cake_Poi.Y + Cake);
                        w = 16;
                        break;
                    }
                case 16://倒L样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y);
                        temporaryArray[3] = new Point(cake_Poi.X - Cake, cake_Poi.Y - Cake);
                        w = 17;
                        break;
                    }
                case 17://倒L样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        temporaryArray[3] = new Point(cake_Poi.X + Cake, cake_Poi.Y - Cake);
                        w = 14;
                        break;
                    }
                case 18://倒Z
                    {
                        temporaryArray[1] = new Point(cake_Poi.X, cake_Poi.Y - Cake);
                        temporaryArray[2] = new Point(cake_Poi.X + Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        w = 19;
                        break;
                    }
                case 19://倒Z样式
                    {
                        temporaryArray[1] = new Point(cake_Poi.X - Cake, cake_Poi.Y);
                        temporaryArray[2] = new Point(cake_Poi.X - Cake, cake_Poi.Y - Cake);
                        temporaryArray[3] = new Point(cake_Poi.X, cake_Poi.Y + Cake);
                        w = 18;
                        break;
                    }



            }
            bool a = true;//判断方块是否可变
            for (int i = 0; i < temporaryArray.Length; i++)
            {
                if (temporaryArray[i].X / 20 < 0)//变换后是否超出左边界
                {
                    a = false;//不变换
                    break;
                }
                if (temporaryArray[i].X / 20 >= conWidth)//变换后是否超出右边界
                {
                    a = false;
                    break;
                }
                if (temporaryArray[i].Y / 20 >= conHeight)//变换后是否超出下边界
                {
                    a = false;
                    break;
                }
                if (Place[temporaryArray[i].X / 20, temporaryArray[i].Y / 20])//变换后是否与其他方块重叠
                {
                    a = false;
                    break;
                }
            }
            if (a)//如果当前方块可以变换
            {
                //改变当前方块的样式
                for (int i = 0; i < temporaryArray.Length; i++)
                {
                    ArryPoi[i] = temporaryArray[i];
                    firstcake = cake_Poi;//获取当前方块的起始位置
                    Con = w;//获取方块下一次的变换样式
                }
            }
        }

        /// <summary>
        /// 绘制出一块方块
        /// g=Graphics封装一个绘图的类对象
        /// SolidB=SolidBrush画刷
        ///  rect= Rectangle 绘制区域
        ///  详情查看课本14章
        ///  </summary>
        public void CakePaint(Graphics g, SolidBrush SolidB, Rectangle rect)
        {
            g.FillRectangle(SolidB, rect);//填充矩形
        }

        /// <summary>
        /// 清空游戏背景
        /// </summary>
        public void GameBackClear()
        {
            if (Mycontrol != null)//如要已载入背景控件
            {
                Graphics g = Mycontrol.CreateGraphics();
                Rectangle rect = new Rectangle(0, 0, Mycontrol.Width, Mycontrol.Height);//获取背景的区域
                CakePaint(g, new SolidBrush(Color.Black), rect);//用背景色填充背景
            }
        }

        /// <summary>
        /// 清除方块运行时的痕迹
        /// </summary>
        public void GameSportDelete()
        {
            Graphics g = Mycontrol.CreateGraphics();
            for (int i = 0; i < ArryPoi.Length; i++)
            {
                Rectangle rect = new Rectangle(ArryPoi[i].X, ArryPoi[i].Y, 20, 20);//获取各子方块的区域
                CakePaint(g, new SolidBrush(Color.Black), rect);//用背景色填充背景
            }
        }

         /// <summary>
        /// 绘制组合方块
        /// </summary>
        public void ProtractCake(Control control)
        {
            Mycontrol = control;
            Graphics g = control.CreateGraphics();//背景控件
            //绘制方块的各个子方块
            for (int i = 0; i < ArryPoi.Length; i++)
            {
                Rectangle rect = new Rectangle(ArryPoi[i].X + 1, ArryPoi[i].Y + 1, 18, 18);
                CakePaint(g, new SolidBrush(CakeColor), rect);//绘制子方块
            }
        }

        /// <summary>
        /// 去除已添满的行
        /// </summary>
        public void MoveRow(int max, int min)
        {
            Graphics g = Mycontrol.CreateGraphics();
            int t_max = max / 20;
            int t_min = min / 20;//获取方块的最小位置在多少行
            bool a = false;//初始化记录刷新行的数组
            for (int i = 0; i < 4; i++)
            {
                tem_Array[i] = false;
            }
            int tem_n = maxY;//记录最高行的位置
            for (int i = 0; i < 4; i++)//查找要刷新的行
            {
                if ((t_min + i) > 19)//如果超出边界20
                    break;//退出本次操作
                a = false;               
                for (int k = 0; k < conWidth; k++)//如果当前行中有空格
                {
                    if (!Place[k, t_min + i])//如果当前位置为空
                    {
                        a = true;
                        break;
                    }
                }
                if (!a)//如要当行为满行
                {
                    tem_Array[i] = true;//记录为刷新行
                }
            }

            int dele = 0;//记录去除的几行
            if (tem_Array[0] == true || tem_Array[1] == true || tem_Array[2] == true || tem_Array[3] == true)//如果有刷新行
            {
                int minrow = 0;//记录最小行数
                for (int i = (tem_Array.Length - 1); i >= 0; i--)//遍历记录刷新行的数组
                {
                    if (tem_Array[i])//如果是刷新行
                    {
                        minrow = min / 20 + i;//记录最小行数
                        //将刷新行到背景顶端的区域下移
                        for (int j = minrow; j >= 1; j--)
                        {
                            for (int k = 0; k < conWidth; k++)
                            {
                                PlaceColor[k, j] = PlaceColor[k, j - 1];//记录方块的位置
                                Place[k, j] = Place[k, j - 1];//记录方块的位置
                            }
                        }
                        min += 20;//方块的最小位置下移一个方块位
                        for (int k = 0; k < conWidth; k++)
                        {
                            PlaceColor[k, 0] = Color.Black;//记录方块的位置
                            Place[k, 0] = false;//记录方块的位置
                        }
                        dele += 1;//记录刷新的行数
                    }
                    
                }

                //在背景中绘制刷新后的方块图案
                for (int i = 0; i < conWidth; i++)//conWidth为记录列数
                {
                    for (int j = 0; j <= max / 20; j++)
                    {
                        Rectangle r = new Rectangle(i * Cake + 1, j * Cake + 1, 19, 19);//获取各方块的区域
                        CakePaint(g, new SolidBrush(PlaceColor[i, j]), r);//绘制已落下的方块
                    }
                }
                hang.Text = Convert.ToString(Convert.ToInt32(hang.Text) + dele);
                fenshu.Text = Convert.ToString(Convert.ToInt32(fenshu.Text) + ArrayCent[dele]);
               
            }
            
        }

        ///<summary>
        ///判断方块移动时是否出边界
        /// 判断移动停止
        ///</summary>
        public bool MoveStop(int n)
        {
            bool a = true;
            int width = 0;
            int height = 0;
            switch (n)
            {
                case 0://下移
                    {
                        for (int i = 0; i < Arryfront.Length; i++)
                        {
                            width = Arryfront[i].X / 20;//获取横向坐标
                            height = Arryfront[i].Y / 20;//获取纵向坐标
                            if (height == conHeight || Place[width, height])//判断是否超出底边界,或是与其他方块重叠
                            { a = false; }//超出边界
                        }
                        break;
                    }
                case 1://左移
                    {
                        for (int i = 0; i < Arryfront.Length; i++)
                        {
                            width = Arryfront[i].X / 20;
                            height = Arryfront[i].Y / 20;
                            if (width == -1 || Place[width, height])//是否超出左边界,或是与其他方块重叠
                            { a = false; }
                        }
                        break;
                    }
                case 2://右移
                    {
                        for (int i = 0; i < Arryfront.Length; i++)
                        {
                            width = Arryfront[i].X / 20;
                            height = Arryfront[i].Y / 20;
                            if (width == conWidth || Place[width, height])//判断是否超出右边界,或是与其他方块重叠
                            { a = false; }
                        }
                        break;
                    }
            }
            return a;
        }
      
        ///<summary>
        ///方块的移动
        ///</summary>
        public void ConvertorMove(int n)
        {
            //记录方块移动前的位置
            for (int i = 0; i < Arryfront.Length; i++)
            { Arryfront[i] = ArryPoi[i]; }
            switch (n)
            {
                case 0://下移
                    {

                        for (int i = 0; i < Arryfront.Length; i++)
                        {
                            Arryfront[i] = new Point(Arryfront[i].X, Arryfront[i].Y + Cake);
                        }
                        break;
                    }
                case 1://左移
                    {
                        for (int i = 0; i < Arryfront.Length; i++)
                        {
                            Arryfront[i] = new Point(Arryfront[i].X - Cake, Arryfront[i].Y);
                        }
                        break;
                    }
                case 2://右移
                    {
                        for (int i = 0; i < Arryfront.Length; i++)
                        {
                            Arryfront[i] = new Point(Arryfront[i].X + Cake, Arryfront[i].Y);
                        }
                        break;
                    }
            }

            bool a = MoveStop(n);//记录方块移动后是否出边界
            if (a)//没有
            {
                GameSportDelete();
                for (int i = 0; i < Arryfront.Length; i++)//获取移动后方块的位置
                 ArryPoi[i] = Arryfront[i];
                firstcake = ArryPoi[0];
                ProtractCake(Mycontrol);//绘制移动后方块
            }
            else//方块到底
            {
                if (!a && n == 0)//如果当前方块是下移
                {
                    conMax = 0;//方块落下后的顶端位置
                    conMin = Mycontrol.Height;//记录方块落下后的底端位置
                    for (int i = 0; i < ArryPoi.Length; i++)
                    {
                        if (ArryPoi[i].Y < maxY)//记方块的顶端位置
                            maxY = ArryPoi[i].Y;
                        Place[ArryPoi[i].X / 20, ArryPoi[i].Y / 20] = true;//记录指定的位置已存在方块
                        PlaceColor[ArryPoi[i].X / 20, ArryPoi[i].Y / 20] = CakeColor;
                        if (ArryPoi[i].Y > conMax)
                            conMax = ArryPoi[i].Y;
                        if (ArryPoi[i].Y < conMin)
                            conMin = ArryPoi[i].Y;
                    }
                    if (firstcake.X == 140 && firstcake.Y == 20)
                    {
                        time.Stop();
                        Form1.isbegin = false;
                        MessageBox.Show("游戏结束");
                        return;
                    }

                    Random rand = new Random();//实例化Random
                    int cakerand = rand.Next(1, 8);//获取随机数
                    firstcake = new Point(140, 20);//设置方块的起始位置
                    CakeMode(Form1.Crand);//设置方块的样式
                    ProtractCake(Mycontrol);//绘制组合方块
                    MoveRow(conMax, conMin);//去除已填满的行
                    Form1.b = true;//标识,判断可以生成下一个方块
                }
            }
        }

        /// <summary>
        /// 变换当前方块的样式
        /// </summary>
        public void MyConvertorMode()
        {
            GameSportDelete();
            ConvertorMode(Con);
            ProtractCake(Mycontrol);//变换后的方块
        }

        /// <summary>
        /// 对信息进行初始化
        /// </summary>
        public void PlaceInitialization()
        {
            conWidth = Mycontrol.Width / 20;//布局总行数
            conHeight = Mycontrol.Height / 20;//总列数
            Place = new bool[conWidth, conHeight];//定义记录各方块位置的数组
            PlaceColor = new Color[conWidth, conHeight];//记录各方块颜色的数组
            //对各方块的信息进行初始化
            for (int i = 0; i < conWidth; i++)
            {
                for (int j = 0; j < conHeight; j++)
                {
                    Place[i, j] = false;//方块为空
                    PlaceColor[i, j] = Color.Black;//与背景色相同
                }
            }
            maxY = conHeight * Cake;//记录方块的最大值
        }

    }
}
搜索更多相关主题的帖子: 俄罗斯方块 public false 
2013-06-19 19:08
杰与贤3
Rank: 2
等 级:论坛游民
帖 子:11
专家分:18
注 册:2013-5-17
收藏
得分:0 
[local]1[/local]我的程序包,求修改
2013-06-19 19:23
何事惊慌
Rank: 6Rank: 6
等 级:侠之大者
威 望:4
帖 子:220
专家分:499
注 册:2008-7-2
收藏
得分:0 
方块位移的时候写在timer事件里面试试,0的话特殊处理下,设置timer为false

QQ:860234001
编程交流群:236949758
2013-06-22 21:43
快速回复:俄罗斯方块速度怎么搞,我设的速度都没有用,而且我把速度都删了方块还 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.068036 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved