We'll develop the Flappy Bird game environment using Pygame as follows:
- We start by developing a utility function that loads images and transforms them into the right format:
>>> from pygame.image import load >>> from pygame.surfarray import pixels_alpha >>> from pygame.transform import rotate >>> def load_images(sprites_path): ... base_image = load(sprites_path + 'base.png').convert_alpha() ... background_image = load(sprites_path + 'background-black.png').convert() ... pipe_images = [rotate(load(sprites_path + 'pipe-green.png').convert_alpha(), 180), ... load(sprites_path + 'pipe-green.png').convert_alpha()] ... bird_images = [load(sprites_path + 'redbird-upflap.png').convert_alpha(), ... load(sprites_path + 'redbird-midflap.png').convert_alpha(), ...