在工程基础课上开始学习python。我的家庭作业是移动一个64x64的图像“iulogo.gif”。我必须在(640480)屏幕上移动此图像。我需要在屏幕的所有部分的边缘移动这个图像,从(0,0),到(640,0),到(640,480),和(480,0),回到(0,0)
我的问题是从(640480)到(480,0)再到(0,0)。我以0.5的速度移动。当我向前移动时,我做“x撸U位置+=0.5”和“向下y撸U位置+=0.5”。但当我倒转下来,它说的是无效的语法。I型“-=0.5”
while (1):
while (x_position < 640):
x_position += 0.5
sm.write_x(x_position)
sm.update_screen()
while (y_position < 480):
y_position += 0.5
sm.write_y(y_position)
sm.update_screen()
x_position = 640
sm.write_x(x_position)
y_position = 480
sm.write_x(x_position)
while (x_position <= 640
x_position =- 0.5 #here is the error
sm.write_x(x_position)
sm.update_screen()
while (y_position <= 480):
y_position =- 0.5 #most likely here too
sm.write_y(y_position)
sm.update_screen()
x_position = 0
sm.write_x(x_position)
y_position = 0
sm.write_y(y_position)
我希望x_position-=0.5的输出将其向后移动0.5,但输出只是一个“SyntaxError:invalid syntax”
上面的一行末尾缺少
):
相关问题 更多 >
编程相关推荐