Pygame

# pygame 面向对象最小框架

import pygame

# 全局变量

class MyGame:
    def __init__(self):
        self.__game_init_()
        
    # 游戏初始化
    def __game_init_(self):
        pygame.init()
        window = pygame.display.set_mode((600,400))
        pygame.display.set_caption('大张Python笔记')
    
    # 游戏开始,事件循环
    def start(self):
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    exit()
            pygame.display.update()


if __name__ == '__main__':
    app = MyGame()
    app.start()

results matching ""

    No results matching ""