Game.cs
(开头部分) 12KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tetris
{
internal class Game
{
//定义字段blockImageWidth,表明方块的子区域的宽度
public const int blockImageWidth = 21;
//定义字段blockImageHeight,表明方块的子区域的宽度
public const int blockImageHeight = 21;
//定义字段gameAreaWidth,表明游戏区域的宽度
public const int blocksWidth = 10;
//定义字段gameAreaHeight,表明游戏区域的高度
public const int blocksHeight = 20;
//定义Blocks,表明游戏区域的所有子区域,即游戏区域的所有方块
private readonly int[,] blocks;
//实例化Block类生成对象此方块thisBlock
private Block thisBlock;
//定义字段lines,表明清除的满行数
public int lines = 0;
//实例化Block类生成对象续方块nextBlock
private Block nextBlock;
//定义字段GameOver,表明游戏当前状态
public bool GameOver = false;
//定义字段score,表明分数
public int score = 0;
/// <summary>
/// 定义构造函数 Game() ,初始化游戏区域,默认所有子区域当前状态均为无图片状态,需要续块
/// </summary>
public Game()
{
blocks = new int[blocksWidth, blocksHeight];
Clearblocks();
NextBlock();
}
/// <summary>
/// 定义方法Clearblocks(),默认所有子区域当前状态均为无图片状态即清空游戏区域的所有方块
/// </summary>
private void Clearblocks()
{
for (int i = 0; i < blocksWidth; i++)
{
for (int j = 0; j < blocksHeight; j++)
{
//所有子区域当前状态均为无图片状态
blocks[i, j] = 0;
}
}
}
/// <summary>
/// 定义方法NextBlock(),生成此方块的续方块
/// </summary>
private void NextBlock()
{
//判断是否需要续块
后面还有 311 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。