Beispiel #1
0
    def __init__(self):

        # if the resolution was not changed through cmdline args, use the default scaling
        if self.WIDTH < 1 and self.HEIGHT < 1:
            monitor_info = pygame.display.Info()
            debugger("Display: __init__: Monitor resolution is {}x{}".format(
                monitor_info.current_w, monitor_info.current_h))
            self.WIDTH = int(self.WIDTH * monitor_info.current_w)
            self.HEIGHT = int(self.HEIGHT * monitor_info.current_h)

        # TODO: remove this if font sizes in HUDs are scaled
        if self.HEIGHT < 400:
            debugger(
                "WARNING: flappy-judoka: main: Height resolution is below the recommended value 400!"
            )

        self.display = pygame.display.set_mode((self.WIDTH, self.HEIGHT),
                                               pygame.NOFRAME)
        debugger("Display: __init__: Setting game resolution {}x{}".format(
            self.WIDTH, self.HEIGHT))

        # setting the window name (this is for the window manager to have a reference)
        pygame.display.set_caption(self.GAME_TITLE)

        # hiding mouse pointer when the game runs
        pygame.mouse.set_visible(False)

        # grabing all keyboard and mouse inputs, apps behind the game won't get input
        pygame.event.set_grab(True)

        # initialising and loading assets based on screen resolution
        Assets(self.WIDTH, self.HEIGHT)

        # compose and draw the background
        self.randomise_background()
        self.draw_background()