白桦的天空

第一次的心动,永远的心痛!
随笔 - 349, 文章 - 15, 评论 - 203, 阅读 - 25万
  首页  :: 新随笔  :: 联系 :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

一个标准的pygame例子

Posted on   白桦的天空  阅读(97)  评论(0编辑  收藏  举报
复制代码
import pygame
from pygame.locals import *
import sys
import math

class Game:
    def __init__(self):
        pygame.init()
        self.W,self.H=800,800
        self.screen=pygame.display.set_mode((self.W,self.H))
        pygame.display.set_caption("【Pygame 学习笔记】")

    def listen(self):
        for event in pygame.event.get():
            if event.type==QUIT:
                sys.exit()

    def draw(self):
        self.screen.fill((255,255,255))
        # pygame.draw.rect(self.screen,(255,0,0),(100,100,300,300))
        # pygame.draw.circle(self.screen,(0,255,0),(400,400),30)
        # pygame.draw.line(self.screen,(0,0,255),(300,400),(500,600))
        # pygame.draw.lines(self.screen,(0,0,0),True,[(300,500),(500,700),(700,500)])
        pygame.draw.arc(self.screen,(0,0,255),(100,100,200,200),math.radians(0),math.radians(45))

    def run(self):
        while True:
            self.listen()
            self.draw()
            pygame.display.update()

if __name__ == '__main__':
    game=Game()
    game.run()
复制代码

 

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示