如何在木板上创建寄宿生

问题描述 投票:0回答:1

我正在创建《扫雷游戏》的游戏板,我希望游戏板有一个寄宿生。如何使用箱形图字符来实现此目的?

我能够画板,并且显示效果很好。但这不是寄宿生。这是下面的代码

   public static void PrintBoard(Game game)
        {
            var board = game.GetBoard();
            Console.WriteLine("Contains {0} elements:", board.Length); 
            for (int yIndex = 0; yIndex < game.BoardHeight; yIndex++)
            {
                var line = "";
                for (int xIndex = 0; xIndex < game.BoardWidth; xIndex++)
                {

                    line = line + " " + GetSingleState(board[yIndex, xIndex]) + " ";
                    if (xIndex < game.BoardWidth - 1)
                    {
                        line = line + _verticalSeparator;
                    }
                }

                Console.WriteLine(line);

                if (yIndex < game.BoardHeight - 1)
                {
                    line = "";
                    for (int xIndex = 0; xIndex < game.BoardWidth; xIndex++)
                    {
                        line = line + _horizontalSeparator+ _horizontalSeparator+ _horizontalSeparator;
                        if (xIndex < game.BoardWidth - 1)
                        {
                            line = line +_centerSeparator;
                        }
                    }
                    Console.WriteLine(line);
                }


            }
        }

我现在的板子:(https://imgur.com/NlXMx0e)。

预期的登机牌应与寄宿生类似:([https://imgur.com/5kkpCVt

c# unicode ascii
1个回答
0
投票

“”

#!/usr/bin/env perl
use 5.020;
use utf8;
use Term::ANSIColor qw(color);
my $game = [
    [qw(♔ ♕ ♖ ♗ ♘ ♙)],
    [(' ') x 6],
    [(' ') x 6],
    [(' ') x 6],
    [(' ') x 6],
    [qw(♚ ♛ ♜ ♝ ♞ ♟)],
];
my $blue_circle = color('blue') . '●' . color('reset');
my $game_height = scalar $game->@*;      # 6
my $game_width = scalar $game->[0]->@*;  # 6
my $board_height = $game_height * 2;     # 12
my $board_width = $game_width * 4;       # 24
my $board;
for my $y (0 .. $board_height) {
    $board->[$y] = $y % 2
        ? [
            '|', map {
                (' ', $_, ' ', '|')
            } $game->[($y - 1) / 2]->@*
        ]
        : ['+', qw(- - - +) x $game_width]
}
for my $y (0, $board_height) {
    for my $x (0, $board_width / 2, $board_width) {
        $board->[$y][$x] = $blue_circle;
    }
}
for my $x (0, $board_width) {
    $board->[$board_height / 2][$x] = $blue_circle;
}
for my $row ($board->@*) {
    say join '', $row->@*;
}
© www.soinside.com 2019 - 2024. All rights reserved.