From 105b3cc0959eae1171b37a8593c011f7371f3fd7 Mon Sep 17 00:00:00 2001 From: chaelimee Date: Wed, 29 Nov 2023 17:36:28 +0900 Subject: [PATCH] =?UTF-8?q?main.py=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++---- pygame-SJ | 2 +- 2 files changed, 110 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 7b6c020288e1e..bb4491856b3db 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,113 @@ -from G_baseballGame import baseballGame -#from G_avoid import avoidGame -from G_snake import snakeGame -from G_memoryGame import memoryGame +# main_game.py +import pygame +import sys +from pygame.locals import * -g = snakeGame() +def G_snake(): + pygame.init() -while g.running: - g.game_loop() + screen = pygame.display.set_mode((400, 300)) + pygame.display.set_caption("G_snake") - \ No newline at end of file + font = pygame.font.Font(None, 36) + clock = pygame.time.Clock() + + while True: + screen.fill((255, 255, 255)) + text = font.render("G_snake", True, (0, 0, 0)) + screen.blit(text, (150, 150)) + pygame.display.flip() + + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + + clock.tick(30) + +def G_avoid(): + pygame.init() + + screen = pygame.display.set_mode((400, 300)) + pygame.display.set_caption("G_avoid") + + font = pygame.font.Font(None, 36) + clock = pygame.time.Clock() + + while True: + screen.fill((255, 255, 255)) + text = font.render("G_avoid", True, (0, 0, 0)) + screen.blit(text, (150, 150)) + pygame.display.flip() + + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + + clock.tick(30) + +def G_memoryGame(): + pygame.init() + + screen = pygame.display.set_mode((400, 300)) + pygame.display.set_caption("G_memoryGame") + + font = pygame.font.Font(None, 36) + clock = pygame.time.Clock() + + while True: + screen.fill((255, 255, 255)) + text = font.render("G_memoryGame", True, (0, 0, 0)) + screen.blit(text, (150, 150)) + pygame.display.flip() + + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + + clock.tick(30) + + + +def main(): + pygame.init() + + width, height = 800, 600 + screen = pygame.display.set_mode((width, height)) + pygame.display.set_caption("Main Game") + + font = pygame.font.Font(None, 36) + clock = pygame.time.Clock() + + games = [G_snake, G_avoid, G_memoryGame] + selected_game = 0 + + while True: + screen.fill((255, 255, 255)) + + for i, game in enumerate(games): + text = font.render(f"Game {i + 1}", True, (0, 0, 0)) + screen.blit(text, (width // 2 - 50, 50 + i * 50)) + + pygame.display.flip() + + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + elif event.type == KEYDOWN: + if event.key == K_UP: + selected_game = (selected_game - 1) % len(games) + elif event.key == K_DOWN: + selected_game = (selected_game + 1) % len(games) + elif event.key == K_RETURN: + # 선택된 게임 실행 + games[selected_game]() + + clock.tick(30) + +if __name__ == "__main__": + main() diff --git a/pygame-SJ b/pygame-SJ index c39f31e9dd7a4..a75caf4c549eb 160000 --- a/pygame-SJ +++ b/pygame-SJ @@ -1 +1 @@ -Subproject commit c39f31e9dd7a45e48027525e2c3e59594bb9ec36 +Subproject commit a75caf4c549ebfe2f5dc16bfbbc6d49a26361c9b