【Pygame】屏幕图形绘制

Pygame 是 python 的一个好用的仿真库;
很多研究生用这个库来构建自己的实验环境;


# 导入必要的库
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()
    

猜你喜欢

转载自blog.csdn.net/ao1886/article/details/110444853