import pygame from settings import Settings import game_functions as gf from snake import Snake settings = Settings() #设置屏幕 screen = pygame.display.set_mode((settings.width, settings.height)) #添加游戏标题 pygame.display.set_caption('贪吃蛇') #创建蛇 snake = Snake(settings) def run_game1(): gf.check_play_events(snake) gf.update_screen(settings, screen, snake) def run_game(): while True: if settings.game_mode == 0: gf.show_start(settings,screen) elif settings.game_mode == -1: gf.show_end(settings,screen) snake.reset(settings) elif settings.game_mode == 1: run_game1() if __name__ == "__main__": pygame.init() run_game()