bn::sprite_item class

Contains the required information to generate sprites.

The assets conversion tools generate an object of this type in the build folder for each *.bmp file with sprite type.

Tiles and colors are not copied but referenced, so they should outlive the sprite_item to avoid dangling references.

Constructors, destructors, conversion operators

sprite_item(const sprite_shape_size& shape_size, const span<const tile>& tiles_ref, const span<const color>& colors_ref, bpp_mode bpp, int graphics_count) constexpr
Constructor.
sprite_item(const sprite_shape_size& shape_size, const sprite_tiles_item& tiles_item, const sprite_palette_item& palette_item) constexpr
Constructor.

Public functions

auto shape_size() const -> const sprite_shape_size& constexpr
Returns the shape and size of the output sprites.
auto tiles_item() const -> const sprite_tiles_item& constexpr
Returns the item used to create the tiles of the output sprites.
auto palette_item() const -> const sprite_palette_item& constexpr
Returns the item used to create the color palette of the output sprites.
auto decompress(span<tile> decompressed_tiles_ref, span<color> decompressed_colors_ref) const -> sprite_item
Decompresses the stored data in the tiles referenced by decompressed_tiles_ref and the colors referenced by decompressed_colors_ref.
auto create_sprite(fixed x, fixed y) const -> sprite_ptr
Creates a sprite_ptr using the information contained in this item.
auto create_sprite(fixed x, fixed y, int graphics_index) const -> sprite_ptr
Creates a sprite_ptr using the information contained in this item.
auto create_sprite(const fixed_point& position) const -> sprite_ptr
Creates a sprite_ptr using the information contained in this item.
auto create_sprite(const fixed_point& position, int graphics_index) const -> sprite_ptr
Creates a sprite_ptr using the information contained in this item.
auto create_sprite_optional(fixed x, fixed y) const -> optional<sprite_ptr>
Creates a sprite_ptr using the information contained in this item.
auto create_sprite_optional(fixed x, fixed y, int graphics_index) const -> optional<sprite_ptr>
Creates a sprite_ptr using the information contained in this item.
auto create_sprite_optional(const fixed_point& position) const -> optional<sprite_ptr>
Creates a sprite_ptr using the information contained in this item.
auto create_sprite_optional(const fixed_point& position, int graphics_index) const -> optional<sprite_ptr>
Creates a sprite_ptr using the information contained in this item.

Friends

auto operator==(const sprite_item& a, const sprite_item& b) -> bool defaulted constexpr
Default equal operator.

Function documentation

bn::sprite_item::sprite_item(const sprite_shape_size& shape_size, const span<const tile>& tiles_ref, const span<const color>& colors_ref, bpp_mode bpp, int graphics_count) constexpr

Constructor.

Parameters
shape_size Shape and size of the output sprites.
tiles_ref Reference to one or more sprite tile sets.
colors_ref Reference to an array of multiples of 16 colors.
bpp Bits per pixel of the output sprites.
graphics_count Number of sprite tile sets contained in tiles_ref.

The tiles are not copied but referenced, so they should outlive the sprite_item to avoid dangling references.

The colors are not copied but referenced, so they should outlive the sprite_item to avoid dangling references.

bn::sprite_item::sprite_item(const sprite_shape_size& shape_size, const sprite_tiles_item& tiles_item, const sprite_palette_item& palette_item) constexpr

Constructor.

Parameters
shape_size Shape and size of the output sprites.
tiles_item It creates the tiles of the output sprites.
palette_item It creates the color palette of the output sprites.

sprite_item bn::sprite_item::decompress(span<tile> decompressed_tiles_ref, span<color> decompressed_colors_ref) const

Decompresses the stored data in the tiles referenced by decompressed_tiles_ref and the colors referenced by decompressed_colors_ref.

Parameters
decompressed_tiles_ref Destination of the decompressed tiles.
decompressed_colors_ref Destination of the decompressed colors.
Returns A sprite_item pointing to the decompressed tiles and colors.

If the source and destination tiles or colors overlap, the behavior is undefined.

sprite_ptr bn::sprite_item::create_sprite(fixed x, fixed y) const

Creates a sprite_ptr using the information contained in this item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
Returns The requested sprite_ptr.

sprite_ptr bn::sprite_item::create_sprite(fixed x, fixed y, int graphics_index) const

Creates a sprite_ptr using the information contained in this item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
graphics_index Index of the tile set to reference in tiles_item().
Returns The requested sprite_ptr.

sprite_ptr bn::sprite_item::create_sprite(const fixed_point& position) const

Creates a sprite_ptr using the information contained in this item.

Parameters
position Position of the sprite.
Returns The requested sprite_ptr.

sprite_ptr bn::sprite_item::create_sprite(const fixed_point& position, int graphics_index) const

Creates a sprite_ptr using the information contained in this item.

Parameters
position Position of the sprite.
graphics_index Index of the tile set to reference in tiles_item().
Returns The requested sprite_ptr.

optional<sprite_ptr> bn::sprite_item::create_sprite_optional(fixed x, fixed y) const

Creates a sprite_ptr using the information contained in this item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

optional<sprite_ptr> bn::sprite_item::create_sprite_optional(fixed x, fixed y, int graphics_index) const

Creates a sprite_ptr using the information contained in this item.

Parameters
x Horizontal position of the sprite.
y Vertical position of the sprite.
graphics_index Index of the tile set to reference in tiles_item().
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

optional<sprite_ptr> bn::sprite_item::create_sprite_optional(const fixed_point& position) const

Creates a sprite_ptr using the information contained in this item.

Parameters
position Position of the sprite.
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.

optional<sprite_ptr> bn::sprite_item::create_sprite_optional(const fixed_point& position, int graphics_index) const

Creates a sprite_ptr using the information contained in this item.

Parameters
position Position of the sprite.
graphics_index Index of the tile set to reference in tiles_item().
Returns The requested sprite_ptr if it could be allocated; bn::nullopt otherwise.