pygame基础教程第一章

1.安装pygame

install win:

pip install pygame

install mac:

pip install https://github.com/pygame/pygame/archive/master.zip

 2.导入pygame库

import pygame

3.pygame的helloworld:

import pygame
from pygame.locals import *
import sys
 
# 使用pygame之前必须初始化
pygame.init()

# 设置用于显示的窗口,单位为像素
screen = pygame.display.set_mode((350, 500))
# 设置标题
pygame.display.set_caption("Hello,World!")
 
while True:
    for event in pygame.event.get():  # 循环获取事件
        if event.type == QUIT:  # 若检测到事件类型为退出,则退出系统
            pygame.quit()
            sys.exit()
    pygame.display.update()  # 更新屏幕内容

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值