• 大小: 909KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-11-07
  • 语言: 其他
  • 标签:

资源简介

根据网上视频学习制作的俄罗斯方块游戏,进行了优化,有完整的代码,用C#语言编写的,可以自己设置方块样式,总共10关,一关100分,1000分通关

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Drawing;
using System.Text;

namespace Tetris
{
    class Block
    {
        protected Point[] structArr;//存放砖块组成信息的坐标数组
        protected int _xPos;//砖块中心点所在的X坐标
        protected int _yPos;//砖块中心点所在的y坐标
        protected Color _blockColor;//砖块颜色
        protected Color disapperColor;//擦除颜色
        protected int rectPix;//每单元格像素
        public Block()//默认构造函数,声明此构造函数是为了子类能创建
        {
 
        }
        public Block(Point[] sa Color bColor Color dColor int pix)
        {
            //重载构造函数,给成员变量赋值
            _blockColor = bColor;
            disapperColor = dColor;
            rectPix = pix;
            structArr = sa;
        }
        public Point this[int index]//索引器,根据索引访问砖块里的小方块坐标
        {
            get
            {
                return structArr[index];
            }
        }
        public int Length//属性,表示structArr的长度
        {
            get
            {
                return structArr.Length;
            }
        }
        #region 成员变量相应的属性
        public int XPos
        {
            get
            {
                return _xPos;
            }
            set
            {
                _xPos = value;
            }
        }
        public int YPos
        {
            get
            {
                return _yPos;
            }
            set
            {
                _yPos = value;
            }
        }
        public Color BlockColor
        {
            get
            {
                return _blockColor;
            }
        }
        #endregion
        public void DeasilRotate()//顺时针旋转
        {
            int temp;
            for (int i = 0; i < structArr.Length; i++)
            {
                temp = structArr[i].X;
                structArr[i].X = structArr[i].Y;
                structArr[i].Y = -temp;
            }
        }
        public void ContraRotate()//逆时针旋转
        {
            int temp;
            for (int i = 0; i < structArr.Length; i++)
            {
                temp = structArr[i].X;
                structArr[i].X = -structArr[i].Y;
                structArr[i].Y = temp;
            }
        }
        private Rectangle PointToRect(Point p)//把坐标点转化为画布的坐标值
        {
            return new Rectangle((_xPos + p.X) * rectPix + 1
                (_yPos - p.Y) * rectPix + 1
                rectPix - 2
                rectPix - 2);
        }
        public virtual void Paint(Graphics gp)//在指定画板下绘制砖块
        {
            SolidBrush sb = new SolidBrush(_blockColor );
            foreach (Point p in structArr)
            {
                lock (gp)
                {
                    gp.FillRectangle(sb PointToRect(p));
                }
            }
        }
        public void erase(Graphics gp)//擦除矩形
        {
            SolidBrush sb = new SolidBrush(disapperColor);
            foreach (Point p in 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        907  2009-10-22 08:23  Tetris\Tetris.sln

    ..A..H.     53760  2009-12-23 21:58  Tetris\Tetris.suo

     文件       3343  2009-11-08 22:59  Tetris\Tetris\Block.cs

     文件       1673  2009-11-09 18:24  Tetris\Tetris\BlockGroup.cs

     文件       1181  2009-11-05 10:02  Tetris\Tetris\BlockInfo.cs

     文件       1097  2009-11-11 09:55  Tetris\Tetris\BlockSet.xml

     文件      10366  2009-11-11 13:22  Tetris\Tetris\Config.cs

     文件       1835  2009-10-22 09:42  Tetris\Tetris\Form1.cs

     文件       4273  2009-10-22 09:24  Tetris\Tetris\Form1.Designer.cs

     文件       5814  2009-10-22 09:24  Tetris\Tetris\Form1.resx

     文件      10679  2009-11-11 13:35  Tetris\Tetris\FrmConfig.cs

     文件      26280  2009-11-08 15:42  Tetris\Tetris\FrmConfig.Designer.cs

     文件       6014  2009-11-08 15:42  Tetris\Tetris\FrmConfig.resx

     文件       2953  2009-11-11 12:55  Tetris\Tetris\InfoArr.cs

     文件      15069  2009-12-23 21:58  Tetris\Tetris\Palette.cs

     文件        469  2009-11-09 18:42  Tetris\Tetris\Program.cs

     文件       5876  2009-11-24 16:36  Tetris\Tetris\Tetris.csproj

     文件        536  2009-12-06 17:03  Tetris\Tetris\Tetris.csproj.user

     文件       1724  2009-11-24 16:32  Tetris\Tetris\Tetris_TemporaryKey.pfx

     文件      86084  2009-11-11 11:18  Tetris\Tetris\Resources\1.jpg

     文件      14020  2009-11-10 22:59  Tetris\Tetris\Resources\123.jpg

     文件       1168  2009-10-22 08:23  Tetris\Tetris\Properties\AssemblyInfo.cs

     文件       3322  2009-11-11 11:58  Tetris\Tetris\Properties\Resources.Designer.cs

     文件       6429  2009-11-11 11:58  Tetris\Tetris\Properties\Resources.resx

     文件       1089  2009-10-22 08:23  Tetris\Tetris\Properties\Settings.Designer.cs

     文件        249  2009-10-22 08:23  Tetris\Tetris\Properties\Settings.settings

     文件        631  2009-12-23 21:57  Tetris\Tetris\obj\Tetris.csproj.FileList.txt

     文件      53248  2009-11-19 09:13  Tetris\Tetris\obj\Debug\AxInterop.WMPLib.dll

     文件     290816  2009-11-19 09:12  Tetris\Tetris\obj\Debug\Interop.WMPLib.dll

     文件       1463  2009-12-06 17:01  Tetris\Tetris\obj\Debug\Tetris.application

............此处省略44个文件信息

评论

共有 条评论

相关资源