我如何使自己的形状移动?我希望它使用提供的while语句移动
pygame.draw.circle(screen, btms3, (250, 187.5), 125, 2)
pygame.display.update()
x=10
y=10
running = 1
while running:
if x <=10:
hmove = 1
elif x >= 350:
hmove = -1
if hmove == 1:
x += 1
elif hmove == -1:
x += -1
我该如何按照标题所说的? 我确实有pygame flip和显示更新和这样的更新内容,但是我无法显示,因为我不想拥有一个超长的代码。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在应用程序循环中移动对象,并且必须在每个帧中重新绘制场景。循环中圆的中心坐标并在每个帧中在其新位置绘制圆圈:
//i.sstatic.net/2eot1.gif“ rel =“ nofollow noreferrer”>
pygame.time.clock.tick
pygame.event.pump()
或BLIT
所有对象)You have to move the object in the application loop and you have to redraw the scene in every frame.Change the center coordinates of the circle in the loop and draw the circle at its new location in each frame:
The typical PyGame application loop has to:
pygame.time.Clock.tick
pygame.event.pump()
orpygame.event.get()
.blit
all the objects)pygame.display.update()
orpygame.display.flip()