(self, id, sprite, tile_x_offset=0, tile_y_offset=0)
Sets pixel data in the spritesheet.

        The given sprite pattern is drawn onto the spritesheet using
        the given tile ID as the upper left corner of the sprite. The
        sprite data is an iterable (rows) of iterables (columns) of
        bytes (pixel colors), similar to the data structure returned
        by get_sprite(). The pixels are drawn onto the 16 tile x 16
        tile spritesheet. If the given sprite data extends to the
        right or below the spritesheet, the excess is clipped.

        To draw the given sprite data offset from the upper left
        corner of a tile, specify a non-zero tile_x_offset or
        tile_y_offset.

        If a pixel value is gfx.TRANSPARENT, the existing pixel data
        in that location is preserved. A pixel value of gfx.BLACK
        overwrites the pixel (even though "black" is transparent by
        default when blitting sprites in PICO-8).

        All rows of the sprite data are assumed to be
        left-aligned. Rows can be of different lengths to leave pixels
        to the right of each row unchanged. To leave pixels on the
        left side of a row unchanged, use gfx.TRANSPARENT values.

        Using a combination of these features, it is possible to paint
        graphics data of an arbitrary shape at an arbitrary location
        on the spritesheet.

        Args:
          id: The PICO-8 tile ID that is the upper-left corner of the requested
            sprite.
          sprite: The sprite pixel data, as an iterable of iterables of pixel
            color values.
          tile_x_offset: If non-zero, start drawing the sprite data onto the
            spritesheet this many pixels to the right of the left edge of the
            tile with the given ID.
          tile_y_offset: If non-zero, start drawing the sprite data onto the
            spritesheet this many pixels below the top edge of the tile with
            the given ID.
Sets pixel data in the spritesheet.
Sets pixel data in the spritesheet .
def set_sprite(self, id, sprite, tile_x_offset=0, tile_y_offset=0):
        """Sets pixel data in the spritesheet.

        The given sprite pattern is drawn onto the spritesheet using
        the given tile ID as the upper left corner of the sprite. The
        sprite data is an iterable (rows) of iterables (columns) of
        bytes (pixel colors), similar to the data structure returned
        by get_sprite(). The pixels are drawn onto the 16 tile x 16
        tile spritesheet. If the given sprite data extends to the
        right or below the spritesheet, the excess is clipped.

        To draw the given sprite data offset from the upper left
        corner of a tile, specify a non-zero tile_x_offset or
        tile_y_offset.

        If a pixel value is gfx.TRANSPARENT, the existing pixel data
        in that location is preserved. A pixel value of gfx.BLACK
        overwrites the pixel (even though "black" is transparent by
        default when blitting sprites in PICO-8).

        All rows of the sprite data are assumed to be
        left-aligned. Rows can be of different lengths to leave pixels
        to the right of each row unchanged. To leave pixels on the
        left side of a row unchanged, use gfx.TRANSPARENT values.

        Using a combination of these features, it is possible to paint
        graphics data of an arbitrary shape at an arbitrary location
        on the spritesheet.

        Args:
          id: The PICO-8 tile ID that is the upper-left corner of the requested
            sprite.
          sprite: The sprite pixel data, as an iterable of iterables of pixel
            color values.
          tile_x_offset: If non-zero, start drawing the sprite data onto the
            spritesheet this many pixels to the right of the left edge of the
            tile with the given ID.
          tile_y_offset: If non-zero, start drawing the sprite data onto the
            spritesheet this many pixels below the top edge of the tile with
            the given ID.
        """
        first_tile_row = id // 16
        first_tile_col = id % 16
        first_x_coord = first_tile_col * 8 + tile_x_offset
        first_y_coord = first_tile_row * 8 + tile_y_offset
        for y, row in enumerate(sprite):
            for x, val in enumerate(row):
                if ((val == TRANSPARENT) or
                    ((first_y_coord + y) > 128) or
                        ((first_x_coord + x) > 128)):
                    continue
                data_loc = (first_y_coord + y) * 64 + (first_x_coord + x) // 2
                b = self._data[data_loc]
                if (first_x_coord + x) % 2 == 0:
                    b = (b & 0xf0) + val
                else:
                    b = (b & 0x0f) + (val << 4)
                self._data[data_loc] = b
def set_sprite ( self , id , sprite , tile_x_offset = 0 , tile_y_offset = 0 ) : first_tile_row = id // 16 first_tile_col = id % 16 first_x_coord = first_tile_col * 8 + tile_x_offset first_y_coord = first_tile_row * 8 + tile_y_offset for y , row in enumerate ( sprite ) : for x , val in enumerate ( row ) : if ( ( val == TRANSPARENT ) or ( ( first_y_coord + y ) > 128 ) or ( ( first_x_coord + x ) > 128 ) ) : continue data_loc = ( first_y_coord + y ) * 64 + ( first_x_coord + x ) // 2 b = self . _data [ data_loc ] if ( first_x_coord + x ) % 2 == 0 : b = ( b & 0xf0 ) + val else : b = ( b & 0x0f ) + ( val << 4 ) self . _data [ data_loc ] = b