我需要从我的部队类中更新游戏的 init 功能中的游戏列表和变量。
# trying to make a game
# here is a quick summary of what I am trying to accomplish
class Game(object):
def __init__(self):
self.var1 = 0
self.xlist = [1, 2, 3]
self.ylist = [6, 5, 4]
def mainloop(self)
for x in range(0, len(self.xlist))
t = Troop(self.xlist[x], self.ylist[x])
class Troop(Game):
def ally(self, x, y):
x += 1
# ^--v these formulas are more complex in the game
y += 1
# v-- what I need to update from Troop class
# var1, xlist, and ylist
# code code code
# code code code
Troop类基本上复制了这些变量并列出并仅更改它们。他们的完整游戏没有正确更新。