From 03003dac5c7b5e8fe5de9a034f91e477ca7132e6 Mon Sep 17 00:00:00 2001 From: pjy6q9iuf <2080284165@qq.com> Date: Fri, 31 May 2024 16:21:23 +0800 Subject: [PATCH] ADD file via upload --- gamestart.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 gamestart.py diff --git a/gamestart.py b/gamestart.py new file mode 100644 index 0000000..bc8bb0a --- /dev/null +++ b/gamestart.py @@ -0,0 +1,33 @@ +''' +游戏开始界面 +''' +import sys +import pygame +from modules.sprites.dinosaur import Dinosaur + + +'''游戏开始界面''' +def GameStartInterface(screen, sounds, cfg): + dino = Dinosaur(cfg.IMAGE_PATHS['dino']) + ground = pygame.image.load(cfg.IMAGE_PATHS['ground']).subsurface((0, 0), (83, 19)) + rect = ground.get_rect() + rect.left, rect.bottom = cfg.SCREENSIZE[0]/20, cfg.SCREENSIZE[1] + clock = pygame.time.Clock() + press_flag = False + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_SPACE or event.key == pygame.K_UP: + press_flag = True + dino.jump(sounds) + dino.update() + screen.fill(cfg.BACKGROUND_COLOR) + screen.blit(ground, rect) + dino.draw(screen) + pygame.display.update() + clock.tick(cfg.FPS) + if (not dino.is_jumping) and press_flag: + return True \ No newline at end of file