def center(self, coords):
        """ center the map on a "map pixel"
        """
        x, y = [round(i, 0) for i in coords]
        self.view_rect.center = x, y

        tw, th = self.data.tile_size

        left, ox = divmod(x, tw)
        top, oy = divmod(y, th)

        vec = int(ox / 2), int(oy)

        iso = vector2_to_iso(vec)
        self._x_offset = iso[0]
        self._y_offset = iso[1]

        print(self._tile_view.size)
        print(self._buffer.get_size())

        # center the buffer on the screen
        self._x_offset += (self._buffer.get_width() - self.view_rect.width) // 2
        self._y_offset += (self._buffer.get_height() - self.view_rect.height) // 4

        # adjust the view if the view has changed without a redraw
        dx = int(left - self._tile_view.left)
        dy = int(top - self._tile_view.top)
        view_change = max(abs(dx), abs(dy))

        # force redraw every time: edge queuing not supported yet
        self._redraw_cutoff = 0

        if view_change and (view_change <= self._redraw_cutoff):
            self._buffer.scroll(-dx * tw, -dy * th)
            self._tile_view.move_ip(dx, dy)
            self._queue_edge_tiles(dx, dy)
            self._flush_tile_queue()

        elif view_change > self._redraw_cutoff:
            # logger.info('scrolling too quickly.  redraw forced')
            self._tile_view.move_ip(dx, dy)
            self.redraw_tiles()
def center ( self , coords ) : x , y = [ round ( i , 0 ) for i in coords ] self . view_rect . center = x , y tw , th = self . data . tile_size left , ox = divmod ( x , tw ) top , oy = divmod ( y , th ) vec = int ( ox / 2 ) , int ( oy ) iso = vector2_to_iso ( vec ) self . _x_offset = iso [ 0 ] self . _y_offset = iso [ 1 ] print ( self . _tile_view . size ) print ( self . _buffer . get_size ( ) ) self . _x_offset += ( self . _buffer . get_width ( ) - self . view_rect . width ) // 2 self . _y_offset += ( self . _buffer . get_height ( ) - self . view_rect . height ) // 4 dx = int ( left - self . _tile_view . left ) dy = int ( top - self . _tile_view . top ) view_change = max ( abs ( dx ) , abs ( dy ) ) self . _redraw_cutoff = 0 if view_change and ( view_change <= self . _redraw_cutoff ) : self . _buffer . scroll ( - dx * tw , - dy * th ) self . _tile_view . move_ip ( dx , dy ) self . _queue_edge_tiles ( dx , dy ) self . _flush_tile_queue ( ) elif view_change > self . _redraw_cutoff : self . _tile_view . move_ip ( dx , dy ) self . redraw_tiles ( )
center the map on a "map pixel"