Program.cs

(开头部分) 5KB

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

using System;
using System.Threading;

class Tetris
{
    static readonly int[,] Shapes = new int[7, 4]
    {
        { 0, 1, 2, 3 },{ 0, 1, 2, 5 },{ 0, 1, 5, 6 },{ 1, 2, 4, 5 },{ 0, 4, 5, 6 },{ 2, 4, 5, 6 },{ 1, 3, 4, 5 }
    };

    const int WIDTH = 10;
    const int HEIGHT = 20;

    static void Main()
    {
        Console.WriteLine("Create By 天球生物");
        System.Threading.Thread.Sleep(3000);
        Console.CursorVisible = false;
        Console.BackgroundColor = ConsoleColor.Black;
        
        StartGame();
    }

    static void StartGame()
    {
        Console.Clear();

        int[,] grid = new int[HEIGHT, WIDTH];

        while (true)
        {
            
            int[] block = CreateBlock();
            int x = WIDTH / 2 - 1;
            int y = 0;

            if (!CanMove(grid, block, x, y))
            {
                Console.SetCursorPosition(WIDTH, 0);
                Console.WriteLine("游戏结束!");
                Console.WriteLine("按任意键重新开始");
                Console.ReadKey(true);
                StartGame();
            }

            while (CanMove(grid, block, x, y + 1))
            {
                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(true).Key;

                    switch (key)
                    {
                        case ConsoleKey.UpArrow:
                            var rotated = RotateClockwise(block);
                            if (CanMove(grid, rotated, x, y)) block = rotated;
                            break;
                        case ConsoleKey.DownArrow:
                            var rotatedCCW = RotateCounterClockwise(block);
                            if (CanMove(grid, rotatedCCW, x, y)) block = rotatedCCW;
后面还有 129 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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