Example #1
0
    def update_board_render_bounds(self):
        position_rect = [-5, -5, 5, 5]
        left, top, right, bottom = 0, 1, 2, 3
        x, y = 0, 1

        for tile in self.tiles:
            position = tile.get_position().get()

            position_rect[left] = min(position[x], position_rect[left])
            position_rect[right] = max(position[x], position_rect[right])

            position_rect[top] = min(position[y], position_rect[top])
            position_rect[bottom] = max(position[y], position_rect[bottom])

        self.__render_bounds = [
            Draw.get_render_position(
                Position([position_rect[left], position_rect[top]])),
            Draw.get_render_position(
                Position([position_rect[right], position_rect[bottom]]))
        ]

        top_left, bottom_right = 0, 1
        self.__render_bounds[top_left][
            x] -= 1.5 * texture_manager.average_width()
        self.__render_bounds[bottom_right][
            x] += 2.5 * texture_manager.average_width()

        self.__render_bounds[top_left][
            y] -= 0.5 * texture_manager.average_height()
        self.__render_bounds[bottom_right][
            y] += 1.5 * texture_manager.average_height()

        Draw.set_render_bounds(self.__render_bounds)
Example #2
0
	def update_board_render_bounds( self ):
		position_rect = [ -5, -5, 5, 5 ]
		left, top, right, bottom = 0, 1, 2, 3
		x, y = 0, 1

		for tile in self.tiles:
			position = tile.get_position().get()

			position_rect[ left ] = min( position[ x ], position_rect[ left ] )
			position_rect[ right ] = max( position[ x ], position_rect[ right ] )

			position_rect[ top ] = min( position[ y ], position_rect[ top ] )
			position_rect[ bottom ] = max( position[ y ], position_rect[ bottom ] )

		self.__render_bounds = [
			Draw.get_render_position( Position( [ position_rect[ left ], position_rect[ top ] ] ) ),
			Draw.get_render_position( Position( [ position_rect[ right ], position_rect[ bottom ] ] ) )
		]

		top_left, bottom_right = 0, 1
		self.__render_bounds[ top_left ][ x ] -= 1.5 * texture_manager.average_width()
		self.__render_bounds[ bottom_right ][ x ] += 2.5 * texture_manager.average_width()

		self.__render_bounds[ top_left ][ y ] -= 0.5 * texture_manager.average_height()
		self.__render_bounds[ bottom_right ][ y ] += 1.5 * texture_manager.average_height()

		Draw.set_render_bounds( self.__render_bounds )
Example #3
0
    def get_render_position(position):
        x_position_modifier = 0
        if not position.is_even_row():
            half_width = texture_manager.average_width() / 2
            x_position_modifier += half_width

        return [(position.get()[0] * texture_manager.average_width()) +
                x_position_modifier,
                position.get()[1] * (texture_manager.average_height() * 0.75)]
Example #4
0
	def get_render_position( position ):
		x_position_modifier = 0
		if not position.is_even_row():
			half_width = texture_manager.average_width() / 2
			x_position_modifier += half_width

		return [ 
			( position.get()[0] * texture_manager.average_width() ) + x_position_modifier, 
			  position.get()[1] * ( texture_manager.average_height() * 0.75 )
		]
Example #5
0
	def coordinate( surface, position ):
		font = pygame.font.SysFont( "monospace", 10 )
		coordinate_label = font.render( str( position ), 1, ( 0, 0, 255 ) )
		
		render_position = Draw.get_render_position( position )
		coordinate_label_position = [ render_position[ 0 ] + ( texture_manager.average_width() / 2 ) - ( coordinate_label.get_width() / 2 ), 
			render_position[ 1 ] + ( texture_manager.average_height() / 2 ) - ( coordinate_label.get_height() / 2 ) ]
		
		Draw.rect( surface, 
			coordinate_label_position[ 0 ],
			coordinate_label_position[ 1 ],
			coordinate_label.get_width(),
			coordinate_label.get_height(), 
			( 255, 255, 255 ) )

		Draw.image_explicit( surface, coordinate_label, *coordinate_label_position )
Example #6
0
    def coordinate(surface, position):
        font = pygame.font.SysFont("monospace", 10)
        coordinate_label = font.render(str(position), 1, (0, 0, 255))

        render_position = Draw.get_render_position(position)
        coordinate_label_position = [
            render_position[0] + (texture_manager.average_width() / 2) -
            (coordinate_label.get_width() / 2),
            render_position[1] + (texture_manager.average_height() / 2) -
            (coordinate_label.get_height() / 2)
        ]

        Draw.rect(surface, coordinate_label_position[0],
                  coordinate_label_position[1], coordinate_label.get_width(),
                  coordinate_label.get_height(), (255, 255, 255))

        Draw.image_explicit(surface, coordinate_label,
                            *coordinate_label_position)