I'm throwing myself at the mercy of the SO community, having looked at the below now for considerable time. I'm attempting to create an animated background for my title screen which loops through eight elements in a list called background_images. By calling the function bg_start_animation in the rocket_settings class, I am expecting to have self.background be populated with the first element of the list, for this to be passed to the main body of the code using return self.background, for this be blit to the screen, have the screen refreshed at display.flip, and then have the process repeated by the other seven elements of the list to create the animation effect.
I store the latest iteration of background image using:
animated_bg = rocket_settings.bg_start_animation()
and blit to the screen:
screen.blit(animated_bg, (0, 0))
please note: rocket_settings calls the Class for which I have copied below the main body of the code.
while True:
pygame.time.delay(5)
gf.check_events(rocket_settings, screen, character)
character.update()
gf.update_screen(rocket_settings, screen, character)
# Redraw the screen during each pass through the loop
character.update()
#screen.blit(rocket_settings.background, (0, 0))
animated_bg = rocket_settings.bg_start_animation()
screen.blit(animated_bg, (0, 0))
screen.blit(rocket_settings.title, (300, 180))
character.blitme()
#print(character.rect.bottom, ", ", character.rect.y) - to identify the coords
#of the desired spawn point by experimenting in runtime.
# Make the most recently drawn screen visible
pygame.display.flip()
relevant part of rocket settings:
def bg_start_animation(self):
# Screen animation loop
background_images = ["images/wick_title_screen_1.bmp",
"images/wick_title_screen_2.bmp", "images/wick_title_screen_3.bmp",
"images/wick_title_screen_4.bmp", "images/wick_title_screen_5.bmp",
"images/wick_title_screen_6.bmp", "images/wick_title_screen_7.bmp",
"images/wick_title_screen_8.bmp"]
for background in background_images:
self.background = pygame.image.load(background)
return self.background
I must be overlooking something. Thanks in advance, I appreciate the assistance.