Esempio n. 1
0
    def pre_game_loop(self):
        self.update()
        check_debug('Pre game loop is start', 'BASE', 1)
        self.loop = Loop(
            loop_name=settings.PRE_GAME_LOOP,
            update=self.update,
            exit_name="pre_game_exit",
            autorun={
                "load_preset": self.load_preset,
            },
            funcs={
                "pre_game_exit": self.pre_game_exit,
                "pre_game_start": self.pre_game_start,
            },
            buttons={
                "pre_game_exit": self.exit_button,
                "pre_game_start": self.start_button,
            },
            mousebuttondown={
                "check_preset": self.check_preset,
            },
            post_for={
                "blit_preset": self.blit_preset,
            },
        )
        self.loop.run()

        check_debug('Pre game loop is over', 'BASE', 1)
Esempio n. 2
0
    def __init__(self):
        pygame.init()
        check_debug('Game init', 'INIT', 1)
        settings.SCREEN.fill((150, 150, 150))
        self.clock = pygame.time.Clock()

        self.exit_button = None
        self.loop = None
Esempio n. 3
0
 def switch_fullscreen():
     settings.FULLSCREEN = not settings.FULLSCREEN
     check_debug(f'Set fullscreen: {settings.FULLSCREEN}', 'SETTING')
     if settings.FULLSCREEN:
         settings.SCREEN = pygame.display.set_mode(
             (settings.WIDTH, settings.HEIGHT), pygame.FULLSCREEN)
     else:
         settings.SCREEN = pygame.display.set_mode(
             (settings.WIDTH, settings.HEIGHT))
Esempio n. 4
0
    def __init__(self):
        pygame.init()
        check_debug('Setting init', 'INIT', 1)
        settings.SCREEN.fill((150, 150, 150))
        self.clock = pygame.time.Clock()

        self.back_button = None
        self.fullscreen_button = None

        self.loop = None
Esempio n. 5
0
 def __init__(self):
     pygame.init()
     check_debug('Front init', 'INIT', 2)
     if settings.FULLSCREEN:
         settings.SCREEN = pygame.display.set_mode(
             (settings.WIDTH, settings.HEIGHT), pygame.FULLSCREEN)
     else:
         settings.SCREEN = pygame.display.set_mode(
             (settings.WIDTH, settings.HEIGHT))
     settings.SCREEN.fill((100, 100, 100))
     pygame.display.set_caption(settings.TITLE)
     self.clock = pygame.time.Clock()
Esempio n. 6
0
 def pre_game_start(self):
     result = True
     for value in settings.PRESET.values():
         if not value:
             result = False
             check_debug('There are empty parameters', 'ALERT')
             break
     if result:
         self.config.setting_dump(json_path.PRESET, settings.PRESET)
         check_debug('Pre game settings saved', 'EVENT')
         settings.PRE_GAME_LOOP = False
         settings.GAME_LOOP = True
         self.loop.stop()
Esempio n. 7
0
    def __init__(self):
        pygame.init()
        check_debug('Pre game init', 'INIT', 1)
        settings.SCREEN.fill((150, 150, 150))
        self.clock = pygame.time.Clock()
        self.config = BaseConfig()

        self.exit_button = None
        self.start_button = None
        self.preset_buttons = {
            'size': [],
            'challenge': [],
            'folk': [],
            'environment': []
        }

        self.loop = None
Esempio n. 8
0
    def setting_loop(self):
        self.update()
        check_debug('Setting loop is start', 'BASE', 1)
        self.loop = Loop(
            loop_name=settings.SETTINGS_LOOP,
            update=self.update,
            exit_name="to_menu",
            funcs={
                "to_menu": self.to_menu,
                "set_fullscrean": self.set_fullscrean
            },
            buttons={
                "to_menu": self.back_button,
                "set_fullscrean": self.fullscreen_button
            },
        )
        self.loop.run()

        check_debug('Setting loop is over', 'BASE', 1)
Esempio n. 9
0
    def menu_loop(self):
        self.update()
        check_debug('Menu loop is start', 'BASE', 1)
        self.loop = Loop(loop_name=settings.MENU_LOOP,
                         update=self.update,
                         exit_name="menu_exit",
                         funcs={
                             "menu_exit": self.menu_exit,
                             "to_setting": self.to_setting,
                             "to_new_game": self.to_new_game,
                         },
                         buttons={
                             "menu_exit": self.exit_button,
                             "to_setting": self.setting_button,
                             "to_new_game": self.new_game_button,
                         },
                         back_img="back/data/image/back/menu_back.png")
        self.loop.run()

        check_debug('Menu loop is over', 'BASE', 1)
Esempio n. 10
0
    def game_loop(self):
        self.update()
        check_debug('Game loop is start', 'BASE', 1)
        self.loop = Loop(
            loop_name=settings.GAME_LOOP,
            update=self.update,
            exit_name="game_exit",
            autorun={
                "load_world_map": world_map.main_world_generator,
            },
            funcs={
                "game_exit": self.game_exit,
            },
            buttons={
                "game_exit": self.exit_button,
            },
        )
        self.loop.run()

        check_debug('Game loop is over', 'BASE', 1)
Esempio n. 11
0
    def choice_loop(self):
        self.update()
        check_debug('Choice loop', 'EVENT')
        while settings.CHOICE_LOOP:
            for ev in pygame.event.get():
                mouse = pygame.mouse.get_pos()
                if ev.type == pygame.QUIT:
                    self.choice_exit()
                if ev.type == pygame.KEYDOWN:
                    if ev.key == pygame.K_ESCAPE:
                        self.choice_exit()
                if ev.type == pygame.MOUSEBUTTONDOWN:
                    if self.apply_button.check(mouse):
                        check_debug('Apply', 'SETTING')
                        self.choice_exit()
                        return True
                    if self.cancel_button.check(mouse):
                        check_debug('Cancel', 'SETTING')
                        self.choice_exit()
                        return False
                if ev.type == pygame.MOUSEMOTION:
                    if self.apply_button.check(mouse):
                        self.apply_button.color = (120, 120, 120)
                    elif self.cancel_button.check(mouse):
                        self.cancel_button.color = (120, 120, 120)
                    else:
                        self.update()

            self.apply_button.draw(settings.SCREEN)
            self.cancel_button.draw(settings.SCREEN)

            pygame.display.update()
            self.clock.tick(settings.FPS)
Esempio n. 12
0
    def info_loop(self):
        self.update()
        check_debug('Info loop', 'EVENT')
        while settings.INFO_LOOP:
            for ev in pygame.event.get():
                mouse = pygame.mouse.get_pos()
                if ev.type == pygame.QUIT:
                    self.info_exit()
                if ev.type == pygame.KEYDOWN:
                    if ev.key == pygame.K_ESCAPE:
                        self.info_exit()
                if ev.type == pygame.MOUSEBUTTONDOWN:
                    if self.apply_button.check(mouse):
                        self.info_exit()
                if ev.type == pygame.MOUSEMOTION:
                    if self.apply_button.check(mouse):self.apply_button.color = (120,120,120)
                    else:
                        self.update()

            self.apply_button.draw(settings.SCREEN)

            pygame.display.update()
            self.clock.tick(settings.FPS)
Esempio n. 13
0
    def game_loop(self):
        menu = Menu()
        setting = Setting()
        pre_game = PreGame()
        game = Game()

        check_debug('Main game loop is start', 'CORE', 3)
        while settings.MAIN_LOOP:
            for ev in pygame.event.get():
                if ev.type == pygame.QUIT:
                    self.game_exit()
                if ev.type == pygame.KEYDOWN:
                    if ev.key == pygame.K_ESCAPE:
                        self.game_exit()

            if settings.MENU_LOOP: menu.menu_loop()
            if settings.SETTINGS_LOOP: setting.setting_loop()
            if settings.PRE_GAME_LOOP: pre_game.pre_game_loop()
            if settings.GAME_LOOP: game.game_loop()
            settings.SCREEN.fill((100, 100, 100))
            pygame.display.update()
            self.clock.tick(settings.FPS)

        check_debug('Main game loop is over', 'CORE', 3)
Esempio n. 14
0
 def menu_exit(self):
     if add_choice('Выйти из игры ?', 500):
         self.switch_scene('Exit')
         check_debug('GAME EXIT !', 'ALERT')
Esempio n. 15
0
 def game_exit(self):
     if add_choice('Выйти в меню ?', 500):
         settings.GAME_LOOP = False
         settings.MENU_LOOP = True
         self.loop.stop()
         check_debug('GAME EXIT !', 'ALERT')