0

I really don't know how to handle this nothing shows up in my pygame window, not even the screen. The fill() line doesn't do anything. Anyone know what the problem is?

import pygame
def game():
    pygame.init()

    black = (0, 0, 0)
    green = (0,255,0)
    running = True
    screen = pygame.display.set_mode((800,600))
    screen.fill(green)
    button_rectangle = pygame.draw.rect(screen,black,(200,150,100,50))

    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

game()
martineau
  • 119,623
  • 25
  • 170
  • 301
  • What's your question? – Code-Apprentice Mar 03 '21 at 00:52
  • This stackoverflow questions should be helpful for you. :) [https://stackoverflow.com/questions/31812433/pygame-sceen-fill-not-filling-up-the-color-properly](https://stackoverflow.com/questions/31812433/pygame-sceen-fill-not-filling-up-the-color-properly) – TerraBug1011 Mar 03 '21 at 00:53
  • @ÁrpádCsepi That question doesn't have anything to do with this question. – Selcuk Mar 03 '21 at 00:56

1 Answers1

4

You have to update the screen in the event loop.

while running: 
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    # Update the screen.
    pygame.display.update()
Umbral Reaper
  • 325
  • 4
  • 9