Backup/Game.cs

(开头部分) 9KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace 俄罗斯方块
{
    class Game
    {
        public const int BlockImageWidth = 21;//方砖中每个小方格的大小
        public const int BlockImageHeight = 21;       
        public const int PlayingFieldWidth = 10;//游戏面板大小
        public const int PlayingFieldHeight = 20;
        private int[,] pile; //存储在游戏面板中的所有方砖;
        private Block currentBlock ;//当前的俄罗斯方块
        private Block nextBlock ;//下一个的俄罗斯方块
        public int score = 0, lines=0;
        public bool over=false;//游戏是否结束
        public Game()//Game类构造函数
        {
            pile = new int[PlayingFieldWidth , PlayingFieldHeight];          
            ClearPile();
            CreateNewBlock();//产生新的俄罗斯方块
        }
        private void ClearPile()//清空游戏面板中的所有方砖
        {
            for (int i = 0; i < PlayingFieldWidth ; i++)
            {
                for (int j = 0; j < PlayingFieldHeight ; j++)
                {
                    pile[i, j]= 0;
                }
            }
        }
        private void CreateNewBlock()//产生新的俄罗斯方块
		{
			if (this.nextBlock != null)
			{
				currentBlock = nextBlock;
			}
			else
			{
				currentBlock = new Block();
			}
			nextBlock = new Block();
		}
        public void DrawPile(Graphics g)
        {
            Image brickImage = Image.FromFile("image/block1.gif");//方砖的图形
            for (int i = 0; i < PlayingFieldWidth ; i++)
            {
                for (int j = 0; j < PlayingFieldHeight ; j++)
                {
                    if (pile[i, j] == 1)
                    {
                        Rectangle rect = new Rectangle(i * BlockImageWidth, j * BlockImageHeight, BlockImageWidth, BlockImageHeight);//(j - 1)
                        g.DrawImage(brickImage, rect);
                    }
                }
            }
        }
后面还有 212 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。