import pygame
from pygame.locals import *
from sys import exit
# pygame初始化
pygame.init()
# 设定屏幕参数,一个分辨率元组
screen = pygame.display.set_mode((640, 480))
while True:
# 退出程序的方法
for event in pygame.event.get():
if event.type == QUIT:
exit()
# 线条,参数:操作对象,颜色(RGB),起始位置,结束位置,线条宽度
pygame.draw.line(screen, (255, 0, 0), (0, 0), (300, 300), width=5)
# 更新画面
pygame.display.update()