美文网首页
Python游戏开发 unit01_Pygame基本套路

Python游戏开发 unit01_Pygame基本套路

作者: 陈华编程 | 来源:发表于2021-06-07 14:11 被阅读0次

    一、安装

    pip3 install pygame -i https://pypi.tuna.tsinghua.edu.cn/simple
    pip3 list | grep pygame
    

    二、固定套路

    #导入pygame库
    import pygame
    #初始化
    pygame.init()
    #创建窗口
    screen = pygame.display.set_mode((width, height))
    #更新窗口
    pygame.display.update()
    #死循环
    while True:
        pass
    

    退出事件

    for event in pygame.event.get():
        if event.type== pygame.QUIT:
            pygame.quit()
            exit()
    

    三、窗口设置

    设置标题

    pygame.display.set_caption('text')
    

    填充背景

    screen.fill((0,0,0))
    

    相关文章

      网友评论

          本文标题:Python游戏开发 unit01_Pygame基本套路

          本文链接:https://www.haomeiwen.com/subject/cryleltx.html