我正在制作一个使用4x4的棋盘的游戏,我想检查一张牌是否已经被按下。在
为此,我用了两块板。一个将用于计算(我想复制的变量),另一个将用于在游戏中显示(原始板称为状态)。在
我有下面的代码,我想复制fusehuntgrid的状态变量,并在同一类的另一个函数中使用它。
从变量中复制的独立变量不会影响它的计算。在
我认为这里的代码处理status和calculations变量是一样的。在
我如何独立对待他们?在class TreasureHuntGrid(GridLayout):
Finish.shuffle()
status = ListProperty(Finish.board) #Return a random lists of lists with 1 and -1
calculations = status
def __init__(self, *args, **kwargs):
super(TreasureHuntGrid, self).__init__(*args, **kwargs)
def button_pressed(self, button):
if self.calculations[row][column] != 2: #Check if it is pressed or not
button.text = {-1: Finish.surrounded(row, column), 1: 'X'}[self.sta$
button.background_color = colours[self.status[row][column]]
self.calculations[row][column] = 2