So answer in question 1 by 1:(因此,以1回答问题1:)
-
Board[][]
mean multi-dimension array (2 in this case) - in the case of the snake game it represent the board where each row is array and the first column is array of arrays(Board[][]
表示多维数组(在这种情况下为2)-在蛇形游戏中,它表示每个行都是数组而第一列是数组数组的棋盘)
- The
.snake
is not a method but an Boolean variable in the cell object which indicate if the snake is present in that specific cell - it has value of one if the snake is there and 0 otherwise.(.snake
不是方法,而是单元格对象中的布尔变量,它指示该特定单元格中是否存在蛇-如果蛇存在,则值为1,否则为0。) This var used where we display the board on screen.(此变量用于在屏幕上显示板的位置。)
- The
enterKey
function is called whenever key is stroke.(每当击键时都会调用enterKey
函数。) Then by the key we specify the snake direction and change the head coordinate accordingly.(然后通过键指定蛇的方向并相应地更改头部坐标。)
As for your question in the title: the .cell
is a object that is the base object of the board - each element in the 2-dimensional array is a dictionary name cell
.(至于标题中的问题: .cell
是一个对象,它是电路板的基础对象-二维数组中的每个元素都是一个字典名称cell
。)
I hope this make it little but clearer(我希望这可以使它变得更清晰) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…