Beispiel #1
0
 def __init__(self):
     self._screen_h = Core.instance().info().current_h
     self._screen_w = Core.instance().info().current_w
     self._buttons = [
         Button(
             int(self._screen_w / 4), int(self._screen_h / 8),
             int(self._screen_w / 2), int(self._screen_h / 8),
             'Громкость эффектов:{0}'.format(FileManager.instance().get(
                 FileName.Setting, "volume")), lambda: False),
         Button(int(self._screen_w / 10), int(self._screen_h / 8),
                int(self._screen_w / 10), int(self._screen_h / 8), '▲',
                self.toggle_up),
         Button(int(self._screen_w / 1.25), int(self._screen_h / 8),
                int(self._screen_w / 10), int(self._screen_h / 8), '▼',
                self.toggle_down),
         Button(
             int(self._screen_w / 4),
             int(self._screen_h / 4) + int(self._screen_h / 8 * 0.29),
             int(self._screen_w / 2), int(self._screen_h / 8),
             'Громкость музыки:{0}'.format(FileManager.instance().get(
                 FileName.Setting, "music_volume")), lambda: False),
         Button(int(self._screen_w / 10),
                int(self._screen_h / 4) + int(self._screen_h / 8 * 0.29),
                int(self._screen_w / 10), int(self._screen_h / 8), '▲',
                self.toggle_music_up),
         Button(int(self._screen_w / 1.25),
                int(self._screen_h / 4) + int(self._screen_h / 8 * 0.29),
                int(self._screen_w / 10), int(self._screen_h / 8), '▼',
                self.toggle_music_down)
     ]
Beispiel #2
0
 def toggle(self):
     fps = not FileManager.instance().get(FileName.Setting, 'fps')
     FileManager.instance().set(FileName.Setting, 'fps', fps)
     self._buttons[2].text = 'Счетчик fps:{0}'.format(
         (lambda x: "Вкл" if x else "Выкл")(fps))
     Core.instance().update_settings()
     UIManager.instance().set_screen(SettingsMode())
Beispiel #3
0
 def toggle_debug(self):
     debug = not FileManager.instance().get(FileName.Setting, 'debug')
     FileManager.instance().set(FileName.Setting, 'debug', debug)
     self._buttons[0].text = 'Debug:{0}'.format((lambda x: "Вкл"
                                                 if x else "Выкл")(debug))
     Core.instance().update_settings()
     UIManager.instance().set_screen(DebugSettingsMode())
Beispiel #4
0
 def reset(self, i):
     if i in self._resolutions:
         FileManager.instance().set(FileName.Setting, "width",
                                    self._resolutions[i][0])
         FileManager.instance().set(FileName.Setting, "height",
                                    self._resolutions[i][1])
         Core.instance().update_settings()
         UIManager.instance().set_screen(ResolutionMode())
Beispiel #5
0
 def __init__(self):
     self._screen_h = Core.instance().info().current_h
     self._screen_w = Core.instance().info().current_w
     self._buttons = [
         Button(int(self._screen_w / 3), int(self._screen_h / 8),
                int(self._screen_w / 3), int(self._screen_h / 8),
                'You win!',
                lambda: UIManager.instance().set_screen(MenuMode()))
     ]
Beispiel #6
0
 def toggle_music_down(self):
     volume = FileManager.instance().get(FileName.Setting, "music_volume")
     if volume > 0:
         volume -= 0.01
     volume = int(100 * volume) / 100
     self._buttons[0].text = 'Громкость музыки:{0}'.format(volume)
     FileManager.instance().set(FileName.Setting, 'music_volume', volume)
     Core.instance().update_settings()
     UIManager.instance().set_screen(VolumeMode())
     AudioManager.instance().set_volume()
Beispiel #7
0
 def toggle_wall(self):
     debug = FileManager.instance().get(FileName.Setting, 'debug')
     wall_debug = not FileManager.instance().get(FileName.Setting,
                                                 'wall_debug')
     if not debug and wall_debug:
         debug = not debug
     FileManager.instance().set(FileName.Setting, 'debug', debug)
     FileManager.instance().set(FileName.Setting, 'wall_debug', wall_debug)
     self._buttons[1].text = 'Wall_debug:{0}'.format(
         (lambda x: "Вкл" if x else "Выкл")(wall_debug))
     Core.instance().update_settings()
     UIManager.instance().set_screen(DebugSettingsMode())
Beispiel #8
0
 def toggle_up(self):
     volume = FileManager.instance().get(FileName.Setting, "volume")
     if volume < 1:
         volume += 0.01
     volume = int(100 * volume) / 100
     if volume == 0.06:
         volume = 0.07
     if volume == 0.57:
         volume = 0.58
     self._buttons[0].text = 'Громкость эффектов:{0}'.format(volume)
     FileManager.instance().set(FileName.Setting, 'volume', volume)
     Core.instance().update_settings()
     UIManager.instance().set_screen(VolumeMode())
     AudioManager.instance().set_volume()
Beispiel #9
0
 def __init__(self):
     # pygame.mixer.music.set_volume(1)
     self._screen_h = Core.instance().info().current_h
     self._screen_w = Core.instance().info().current_w
     self._buttons = [
         Button(
             int(self._screen_w / 3), int(self._screen_h / 8),
             int(self._screen_w / 3), int(self._screen_h / 8), 'Новая игра',
             lambda: UIManager.instance().set_screen(
                 (lambda: DebugMode() if FileManager.instance().get(
                     FileName.Setting, 'debug') else GameMode())())),
         Button(int(self._screen_w / 3),
                int(self._screen_h / 4) + int(self._screen_h / 8 * 0.29),
                int(self._screen_w / 3), int(self._screen_h / 8),
                'Настройки',
                lambda: UIManager.instance().set_screen(SettingsMode()))
     ]
Beispiel #10
0
 def __init__(self):
     self._screen_h = Core.instance().info().current_h
     self._screen_w = Core.instance().info().current_w
     self._buttons = [
         Button(
             int(self._screen_w / 3), int(self._screen_h / 8),
             int(self._screen_w / 3), int(self._screen_h / 8),
             'Debug:{0}'.format(
                 (lambda x: "Вкл"
                  if x else "Выкл")(FileManager.instance().get(
                      FileName.Setting, "debug"))), self.toggle_debug),
         Button(
             int(self._screen_w / 3),
             int(2 * self._screen_h / 8) + int(self._screen_h / 8 * 0.29),
             int(self._screen_w / 3), int(self._screen_h / 8),
             'Wall_debug:{0}'.format(
                 (lambda x: "Вкл"
                  if x else "Выкл")(FileManager.instance().get(
                      FileName.Setting, "wall_debug"))), self.toggle_wall)
     ]
Beispiel #11
0
    def __init__(self):
        AudioManager.instance().set_music(
            'resources/sounds/peacefullmusic.mp3')
        self._level = FileName.Level_0
        self._world = World()
        self._factory = DemoFactory(self._world, self._level)
        self._player = self._factory.create_player()
        GameManager.instance().create(self._world, self._player)
        self._factory.create()

        self._screen_h = pygame.display.Info().current_h
        self._render = WorldRender()
        self._camera = Camera(Core.instance().info().current_w, self._screen_h)
        self._render.set_camera(self._camera)
        self._direction = 0
        self._zoom = 0
        # test PlayerUI
        self._playerUI = PlayerUI(self._player)
Beispiel #12
0
 def __init__(self):
     self._screen = pygame.display.get_surface()
     self._h = Core.instance().info().current_h
     self._camera = None
Beispiel #13
0
from game.core.core import Core
from game.ui_manager.modes import MenuMode

if __name__ == '__main__':
    Core().start(MenuMode())