From 2f7261f59c0f5e91f2dd3ec15ae8f6097ccb3470 Mon Sep 17 00:00:00 2001 From: chicrobot Date: Sun, 26 Jul 2026 01:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E4=B8=BA=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.py | 59 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/start.py b/start.py index b618385..3f61c8f 100644 --- a/start.py +++ b/start.py @@ -1,38 +1,43 @@ import pygame -# 初始化 -pygame.init() - -# 设置窗口大小 -window_size = (1920/2, 1080/2) -screen = pygame.display.set_mode(window_size) - -# 设置标题 -pygame.display.set_caption("Test Name") +from src.config.color import Color +from src.config.game_config import GameConfig rect = [10,20,30,40] -black = (0,0,0) -white = (255,255,255) -def update(): - pass +class Game: + def __init__(self): + # 初始化 + pygame.init() -def main(): - # 运行循环 - running = True - while running: - # 事件处理 - for event in pygame.event.get(): - # 检查是否关闭 - if event.type == pygame.QUIT: - running = False + # 设置窗口大小 + size = (GameConfig.window_x, GameConfig.window_y) + self.screen = pygame.display.set_mode(size) - screen.fill(black) + # 设置标题 + pygame.display.set_caption(GameConfig.game_name) - pygame.draw.rect(screen, white, rect) + # 运行循环 + self.running = True + self.run() - # 更新显示 - pygame.display.update() + 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__": - main() \ No newline at end of file + Game() \ No newline at end of file