I am creating a Flappy Bird clone to learn pygame based on a video tutorial. At this stage, the script is supposed to display a 800x400 window, fill it with black, and overlay an image.
However, when running the script, the window remains white -- it does not fill it with black or overlay the image.
Below is my code:
import pygame
black = (0,0,0)
white = (255,255,255)
pygame.init()
surface = pygame.display.set_mode((800, 400))
pygame.display.set_caption('Helicopter')
clock = pygame.time.Clock()
def helicopter(x, y, image):
surface.blit(image, (x, y))
img = pygame.image.load('helicopter.png')
x = 150
y = 200
game_over = False
while not game_over:
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_over = True
surface.fill(black)
helicopter(x, y, img)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()
I have verified that both surface.fill(black)
executes and that helicopter()
is called.
How do I fix this?
I am using pygame 1.9.6 with python 3.7.3 on macOS 10.14.3.