Ejemplo n.º 1
0
    def __init__(self, 
                 screen_size=(1280,720),
                 tile_pad=10):

        pygame.init()
        self._screen_size = screen_size
        self._screen = pygame.display.set_mode(self._screen_size, 1)

        self._scroll_window = 30

        self._clock = pygame.time.Clock()

        self._tile_pad=tile_pad

        self._board_renderer = \
            BoardRenderer(self)

        self._move_renderer = \
            MoveRenderer(self)

        self._font_manager = \
            FontManager(self)

        self._pan_manager = None

        pygame.mouse.set_visible(True)
Ejemplo n.º 2
0
class MasterRenderer:
    
    def __init__(self, 
                 screen_size=(1280,720),
                 tile_pad=10):

        pygame.init()
        self._screen_size = screen_size
        self._screen = pygame.display.set_mode(self._screen_size, 1)

        self._scroll_window = 30

        self._clock = pygame.time.Clock()

        self._tile_pad=tile_pad

        self._board_renderer = \
            BoardRenderer(self)

        self._move_renderer = \
            MoveRenderer(self)

        self._font_manager = \
            FontManager(self)

        self._pan_manager = None

        pygame.mouse.set_visible(True)

    def load_game(self,
                  game):
        self._game = game
        board = game.board
        self._board_renderer.load_board(board)
        self._pan_manager = PanManager(self)
        self._move_renderer.reset()

    def process_events(self):

        events = pygame.event.get()
        #if self._look_renderer.has_focus():
        #    self._look_renderer.process_events(events)
        #elif self._init_renderer.has_focus():
        #    self._init_renderer.process_events(events)
        #elif self._move_renderer.has_focus():
        #    self._move_renderer.process_events(events)
        #elif self._fire_renderer.has_focus():
        #    self._fir_renderer.process_events(events)

        for event in events:
            if event.type == pygame.QUIT:
                exit(0) 

        self._move_renderer.process_events(events)

        #mouse_pos = pygame.mouse.get_pos()
        #if mouse_pos[0] < self._scroll_window:
        #    self._pan_manager.scroll_left()
        #if mouse_pos[1] < self._scroll_window:
        #    self._pan_manager.scroll_up()
        #if mouse_pos[0] > (self._screen_size[0] - self._scroll_window - 1):
        #    self._pan_manager.scroll_right()
        #if mouse_pos[1] > (self._screen_size[1] - self._scroll_window - 1):
        #    self._pan_manager.scroll_down()

    def render(self):
        """
        Render the whole game.
        """

        self._clock.tick()
        pygame.display.set_caption("FPS %.2f" % self._clock.get_fps())
        self._pan_manager.update_pan()
        self._board_renderer.render_board()        
        self._move_renderer.render()
        # self._message_renderer.render_messages(pan)
        
        pygame.display.flip()

    ### ---------------------------------------------------
    ### EXTERNAL PROPERTY ACCESS
    ### ---------------------------------------------------

    @property
    def hex_rad(self):
        return self._game.hex_rad

    @property
    def tile_pad(self):
        return self._tile_pad

    @property
    def screen_size(self):
        return self._screen_size

    @property
    def screen(self):
        return self._screen

    @property
    def game(self):
        return self._game

    @property
    def board_renderer(self):
        return self._board_renderer

    @property
    def move_renderer(self):
        return self._move_renderer

    @property
    def pan_manager(self):
        return self._pan_manager

    @property
    def font_manager(self):
        return self._font_manager