Pygame入門 図形(四角)を表示する

import pygame
from pygame.locals import *   # 定数QUITを使うため。importしない場合は、pygame.QUITとする。
import sys

SCREEN_SIZE = (400, 300)

def main():
    pygame.init()
    screen = pygame.display.set_mode(SCREEN_SIZE)   # 画面の大きさを設定する
    pygame.display.set_caption('figure')   # 画面のタイトルを設定する

    while True:
        screen.fill((255, 255, 255))   # 画面を白く塗りつぶす

        # 赤色の四角を描く 左上の座標が(10, 10)、長さと高さが(50, 20)
        pygame.draw.rect(screen, (255, 0, 0), Rect(10, 10, 50, 20))
        pygame.display.update()

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

if __name__ == '__main__':
    main()