基本上我是用java创建一个棋盘游戏,并设法使用数组创建看起来像10x10网格的单元格.现在我已经对它们进行了编号,它们从左到右从上到下(如图)
我正在创建一个类似于蛇和梯子游戏的游戏,但它有自己的扭曲.
问题是:如何创建类似于蛇和梯板的曲折板?
这就是它目前的样子:
下面的代码是创建数组并打印它们并对它们进行编号所需的内容.
对象名为Game:
private Cell[][] cell = new Cell[10][10];
public Game(String nameIt)
{
super(nameIt);
JPanel x = new JPanel();
x.setLayout(new GridLayout(10, 10, 2, 2));
for (int r = 0; ir< 10; r++)
for (int c= 0; c < 10; c++)
x.add(cell[r][c] = new Cell(r, c, this));
}
Run Code Online (Sandbox Code Playgroud)
对象命名单元格:
private int row;
private int col;
private int cellNum;
static int count = 0;
public Cell(int row, int column, Game guy)
{
this.ro = row;
this.col = column; …Run Code Online (Sandbox Code Playgroud)