在尝试在乒乓球比赛中为球创造一些运动时,我遇到了一个最烦人的问题。x 和 y 坐标的值不想改变(因为缺少更好的词)。也许这是由于 python 中字符串的不可变特性,或者我对 Python 处理变量的方式有误解。任何帮助将是最受欢迎的:)
x_coordinate = 100
y_coordinate = 100
NORTH_EAST = [x_coordinate + 1, y_coordinate - 1]
NORTH_WEST = [x_coordinate - 1, y_coordinate - 1]
SOUTH_EAST = [x_coordinate + 1, y_coordinate + 1]
SOUTH_WEST = [x_coordinate - 1, y_coordinate + 1]
direction = NORTH_EAST
while True:
print (direction)
x_coordinate = direction[0]
y_coordinate = direction[1]