一、PyGame的安装
打开PyCharm的左上角 “flle” ,找到 “settings”,如下图 进入后,找到Project:untitled 下的Project interperter,右边是我已经安装的模块,如下图: 点击“+” 输入Python进行搜索,如下图: 安装后新建一个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))
运行结果 如需学习资料的小伙伴可以加我微信领取
|