diff --git a/conf/config.ini b/conf/config.ini new file mode 100644 index 0000000..422fb08 --- /dev/null +++ b/conf/config.ini @@ -0,0 +1,3 @@ +[Settings] +difficult=easy +sound=True diff --git a/main.py b/main.py index fd1789b..367966e 100644 --- a/main.py +++ b/main.py @@ -1,23 +1,13 @@ -import pygame from loguru import logger from modules.Game import Game -from modules.GameMenu import menu from modules.Mathematics import start_calculating def main(): logger.info("Игра запущена") start_calculating() - running = True - show_menu = True - while running: - if show_menu: - menu() - show_menu = False - else: - running = False - pygame.display.flip() - game = Game() + from modules.GameMenu import difficulty + game = Game(difficulty) game.start() diff --git a/modules/Game.py b/modules/Game.py index df5051f..49327c1 100644 --- a/modules/Game.py +++ b/modules/Game.py @@ -3,11 +3,11 @@ from modules.Board import Board class Game: - def __init__(self): + def __init__(self, difficulty): pygame.init() size = 500, 500 self.screen = pygame.display.set_mode(size) - pygame.display.set_caption('Чёрное в белое и наоборот') + pygame.display.set_caption(difficulty) self.board = Board(5, 7, self.screen) self.board.set_view(100, 100, 50) self.running = True diff --git a/modules/GameMenu.py b/modules/GameMenu.py index 8f81332..fbdb79c 100644 --- a/modules/GameMenu.py +++ b/modules/GameMenu.py @@ -1,17 +1,25 @@ -import sys -from pygame import * +import pygame +import pygame_menu -def menu(): - init() - DISPLAYPORT = display.set_mode((480, 600)) - display.set_caption('The Lonely Shooter') - background = image.load('styles/background.jpeg').convert() - DISPLAYPORT.blit(background, background.get_rect()) - display.update() - while True: - events = event.poll() - if events.type == KEYDOWN and events.key == K_RETURN: - break - elif events.type == QUIT: - sys.exit() +def set_difficulty(value, _): + global difficulty + difficulty = value[0][0] + + +def start_the_game(): + menu.toggle() + + +difficulty = "" +pygame.init() +surface = pygame.display.set_mode((600, 400)) +mytheme = pygame_menu.themes.THEME_DARK.copy() +mytheme.background_color = pygame_menu.baseimage.BaseImage(image_path='styles/background.jpg') +menu = pygame_menu.Menu('Welcome', 600, 400, theme=mytheme) +menu.add.label("Сложность") +menu.add.selector('', [('Простая', 1), ('Средняя', 2), ('Сложная', 3), ('Проигрывать весело', 4)], + onchange=set_difficulty) +menu.add.button('Play', start_the_game) +menu.add.button('Quit', pygame_menu.events.EXIT) +menu.mainloop(surface) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..22538b2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +dnspython==2.2.1 +loguru==0.6.0 +pip==22.3.1 +pygame==2.1.2 +pymongo==4.3.3 +setuptools==65.6.3 +wheel==0.38.4 diff --git a/styles/background.jpg b/styles/background.jpg new file mode 100644 index 0000000..26b6ad0 Binary files /dev/null and b/styles/background.jpg differ diff --git a/test.py b/test.py index 88834fc..cb60590 100644 --- a/test.py +++ b/test.py @@ -1,4 +1,4 @@ -from modules.Mathematics import recalculation_events, get_random_event - -event = get_random_event() -recalculation_events(event["well"]) +# from modules.Mathematics import recalculation_events, get_random_event +# +# event = get_random_event() +# recalculation_events(event["well"])