我正在尝试制作一款小型汽车游戏,但我遇到了一个问题,背景在冻结之前从上到下滚动两次,在这个过程中形成了奇怪的形状。由于某些原因,如果背景从下向上滚动,则不会发生错误
def main():
run = True
FPS = 60
clock = pygame.time.Clock()
BGY = 0
BGY2 = -BG.get_height()
def redraw():
win.blit(BG, (0,BGY-100))
win.blit(BG, (0,BGY2-100))
pygame.display.update()
while run:
clock.tick(FPS)
redraw()
BGY += 2.5
BGY2 += 2.5
if BGY < BG.get_height() * -1:
BGY = -BG.get_height()
if BGY2 < BG.get_height() * -1:
BGY2 = -BG.get_height()
main()
背景向下移动,因此条件必须为:
如果背景必须向上移动,则必须减小
BGY
和BGY2
:相关问题 更多 >
编程相关推荐