Reputation: 23
When I run the code, the screen is shown as black, until I bring the Pygame window off of my desktop window, then it shows both the white fill and the red rectangle. How do I make it just show the fill without bringing it off of my desktop screen?
import pygame
pygame.init()
screen = pygame.display.set_mode((1200, 800))
run = True
def block(color, x, y, l, w):
pygame.draw.rect(screen, color, pygame.Rect(x, y, l, w))
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
screen.fill((255, 255, 255))
block((255, 0, 0), 150, 150, 50, 50)
pygame.display.flip
Upvotes: 2
Views: 86
Reputation: 986
The last line pygame.display.flip
is incorrect. That line should be a function call, but instead you are simply referencing to the function object and then doing nothing. Instead, replace the last line with pygame.display.flip()
.
Upvotes: 3