Поэтому я пытался внедрить фон прокрутки в мою игру недавно, однако фоновый рисунок игры при перемещении влево по мере продвижения вперед оставляет огромный след, такой как:
Код здесь внизу:
#Game background
background = pg.transform.scale(pg.image.load('splash.jpg'), (WIDTH,HEIGHT))#background size being adjusted to fit a particular screen size
background_xpos = 0 #the x position of the background is at 0 of (0,0)
background_xpos2 = background.get_width() #obtains the width of the background at a certain coordinate
def UpdateGame():
window.blit(background,(background_xpos,0))
window.blit(background,(background_xpos,0))
pg.display.update()
run = True #while the game is running
while run:
clock.tick(FPS) #determines the amount of frames per second
background_xpos = background_xpos - 2
background_xpos2 = background_xpos - 2
if background_xpos < background.get_width() * -1:
background_xpos = background.get_width()
if background_xpos2 < background.get_width() * -1:
background_xpos2 = background.get_width()