Exemple #1
0
    def render(self, surface):

        width = int(self.__render_bounds[1][0] - self.__render_bounds[0][0])
        height = int(self.__render_bounds[1][1] - self.__render_bounds[0][1])
        render_surface = pygame.Surface((width, height))

        # Make sure we render the tiles under beetles first
        rendered_tiles = []
        for tile in self.tiles:

            def render_tile(tile):
                if tile.type == TileType.beetle and tile.tile_underneith is not None:
                    render_tile(tile.tile_underneith)

                tile.render(render_surface)
                rendered_tiles.append(tile)

            if tile not in rendered_tiles:
                render_tile(tile)

        # Render the coordinates of all tiles and their adjacent pieces
        # We're rendering each coordinate multiple times here, but it shouldn't matter too much
        for tile in self.tiles:
            for position in tile.get_position().get_adjacent_positions():
                Draw.coordinate(render_surface, position)

        # Scale and blit our render surface to the screen surface
        scaled_render_surface = pygame.transform.scale(render_surface,
                                                       [width, height])
        surface.blit(scaled_render_surface, [0, 0])
Exemple #2
0
	def render( self, surface ):

		width = int( self.__render_bounds[ 1 ][ 0 ] - self.__render_bounds[ 0 ][ 0 ] )
		height = int( self.__render_bounds[ 1 ][ 1 ] - self.__render_bounds[ 0 ][ 1 ] )
		render_surface = pygame.Surface( ( width, height ) )

		# Make sure we render the tiles under beetles first
		rendered_tiles = []
		for tile in self.tiles:
			def render_tile( tile ):
				if tile.type == TileType.beetle and tile.tile_underneith is not None:
					render_tile( tile.tile_underneith )

				tile.render( render_surface )
				rendered_tiles.append( tile )

			if tile not in rendered_tiles:
				render_tile( tile )

		# Render the coordinates of all tiles and their adjacent pieces
		# We're rendering each coordinate multiple times here, but it shouldn't matter too much
		for tile in self.tiles:
			for position in tile.get_position().get_adjacent_positions():
				Draw.coordinate( render_surface, position )

		# Scale and blit our render surface to the screen surface
		scaled_render_surface = pygame.transform.scale( render_surface, [ width, height ] )
		surface.blit( scaled_render_surface, [ 0, 0 ] )