[Pygame] Screen graphics drawing

Pygame is a useful simulation library for python;
many graduate students use this library to build their own experimental environment;


# 导入必要的库
import pygame, os, sys
from pygame.locals import *

# 帧率
fps = 12

# 颜色
WHITE              =   (255,255,255)
BLACK              =   (  0,  0,  0)
RED                =   (255,  0,  0)
GREEN              =   (  0,255,  0)
BLUE               =   (  0,  0,255)
ORANGE             =   (255,165,  0)

# 初始化
pygame.init()
title      =   pygame.display.set_caption("caption")
window     =   pygame.display.set_mode((1000,800))
clock      =   pygame.time.Clock()
window.fill(WHITE)

# 主循环
while 1:

	clock.tick(fps)
	pygame.display.flip()
		
	# 上方的关闭按钮关闭窗口	
	for event in pygame.event.get():
	    if event.type == QUIT:
	        pygame.quit()
	        sys.exit()
    

Guess you like

Origin blog.csdn.net/ao1886/article/details/110444853