Files
Project1/start.py
T
2026-07-26 01:52:50 +08:00

43 lines
993 B
Python

import pygame
from src.config.color import Color
from src.config.game_config import GameConfig
rect = [10,20,30,40]
class Game:
def __init__(self):
# 初始化
pygame.init()
# 设置窗口大小
size = (GameConfig.window_x, GameConfig.window_y)
self.screen = pygame.display.set_mode(size)
# 设置标题
pygame.display.set_caption(GameConfig.game_name)
# 运行循环
self.running = True
self.run()
def run(self):
while self.running:
# 事件处理
for event in pygame.event.get():
# 检查是否关闭
if event.type == pygame.QUIT:
self.running = False
self.screen.fill(GameConfig.bg_color)
self.update()
# 更新显示
pygame.display.update()
def update(self):
pygame.draw.rect(self.screen, Color.white, rect)
if __name__ == "__main__":
Game()