第一步:打开Pycharm
第二步:点File ->Default Settings->Project Interpreter->点加号
第三步: 搜索Pygame->Install Package
然后就安装好了,新建一个project试试吧。
import pygame, sys
from pygame.locals import *
white = 255,255,255
black = 0,0,0
pygame.init()
screen = pygame.display.set_mode((600, 500))
myfront = pygame.font.Font(None,60)
textImage = myfront.render("Hello Pygame", True, black)
while True:
for event in pygame.event.get():
if event.type in (QUIT, KEYDOWN):
sys.exit()
screen.fill(white)
screen.blit(textImage, (100, 100))
pygame.display.update()
效果如下: