Why the draw rectangle doesn't show in the scr

2019-07-24 04:52发布

I've tried several times running code to display something in the screen but it never shows up anything, it is always a blank screen as you can see:

Blank screen

I want to draw a rectangle, but why is it not displaying?

import pygame, sys
from pygame.locals import *

def main():
    pygame.init()

    DISPLAY=pygame.display.set_mode((500,400),0,32)

    WHITE=(255,255,255)
    blue=(0,0,255)

    DISPLAY.fill(WHITE)

    pygame.draw.rect(DISPLAY,blue,(200,150,100,50))

    while True:
        for event in pygame.event.get():
            if event.type==QUIT:
                pygame.quit()
                sys.exit()
        pygame.display.update()

main()

I'm running Python 3.7.1 and pygame 1.9.4 on macos

标签: python pygame
0条回答
登录 后发表回答