bn::affine_bg_ptr class

std::shared_ptr like smart pointer that retains shared ownership of an affine background.

Several affine_bg_ptr objects may own the same affine background.

The affine background is released when the last remaining affine_bg_ptr owning it is destroyed.

Public static functions

static auto create(const affine_bg_item& item) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create(const affine_bg_item& item, int map_index) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create(affine_bg_map_ptr map) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_map_ptr.
static auto create(fixed x, fixed y, const affine_bg_item& item) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create(fixed x, fixed y, const affine_bg_item& item, int map_index) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create(const fixed_point& position, const affine_bg_item& item) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create(const fixed_point& position, const affine_bg_item& item, int map_index) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create(fixed x, fixed y, affine_bg_map_ptr map) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_map_ptr.
static auto create(const fixed_point& position, affine_bg_map_ptr map) -> affine_bg_ptr
Creates an affine_bg_ptr from the given affine_bg_map_ptr.
static auto create(const affine_bg_builder& builder) -> affine_bg_ptr
Creates an affine_bg_ptr from an affine_bg_builder reference.
static auto create(affine_bg_builder&& builder) -> affine_bg_ptr
Creates an affine_bg_ptr from a moved affine_bg_builder.
static auto create_optional(const affine_bg_item& item) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create_optional(const affine_bg_item& item, int map_index) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create_optional(affine_bg_map_ptr map) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_map_ptr.
static auto create_optional(fixed x, fixed y, const affine_bg_item& item) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create_optional(fixed x, fixed y, const affine_bg_item& item, int map_index) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create_optional(const fixed_point& position, const affine_bg_item& item) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create_optional(const fixed_point& position, const affine_bg_item& item, int map_index) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_item.
static auto create_optional(fixed x, fixed y, affine_bg_map_ptr map) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_map_ptr.
static auto create_optional(const fixed_point& position, affine_bg_map_ptr map) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from the given affine_bg_map_ptr.
static auto create_optional(const affine_bg_builder& builder) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from an affine_bg_builder reference.
static auto create_optional(affine_bg_builder&& builder) -> optional<affine_bg_ptr>
Creates an affine_bg_ptr from a moved affine_bg_builder.

Constructors, destructors, conversion operators

affine_bg_ptr(const affine_bg_ptr& other)
Copy constructor.
affine_bg_ptr(affine_bg_ptr&& other) noexcept
Move constructor.
~affine_bg_ptr()
Releases the referenced affine background if no more affine_bg_ptr objects reference to it.

Public functions

auto operator=(const affine_bg_ptr& other) -> affine_bg_ptr&
Copy assignment operator.
auto operator=(affine_bg_ptr&& other) -> affine_bg_ptr& noexcept
Move assignment operator.
auto dimensions() const -> size
Returns the size in pixels of the affine background.
auto big() const -> bool
Indicates if this affine background is big or not.
auto tiles() const -> const affine_bg_tiles_ptr&
Returns the tiles used by this affine background.
void set_tiles(const affine_bg_tiles_ptr& tiles)
Sets the tiles used by this affine background.
void set_tiles(affine_bg_tiles_ptr&& tiles)
Sets the tiles used by this affine background.
void set_tiles(const affine_bg_tiles_item& tiles_item)
Replaces the tiles used by this affine background with a new tile set created with the given affine_bg_tiles_item.
auto palette() const -> const bg_palette_ptr&
Returns the color palette used by this affine background.
void set_palette(const bg_palette_ptr& palette)
Sets the color palette to use by this affine background.
void set_palette(bg_palette_ptr&& palette)
Sets the color palette to use by this affine background.
void set_palette(const bg_palette_item& palette_item)
Replaces the color palette used by this affine background with a new one created with the given bg_palette_item.
auto map() const -> const affine_bg_map_ptr&
Returns the map used by this affine background.
void set_map(const affine_bg_map_ptr& map)
Sets the map used by this affine background.
void set_map(affine_bg_map_ptr&& map)
Sets the map used by this affine background.
void set_map(const affine_bg_map_item& map_item)
Replaces the map used by this affine background with a new map created with the given affine_bg_map_item.
void set_map(const affine_bg_map_item& map_item, int map_index)
Replaces the map used by this affine background with a new map created with the given affine_bg_map_item.
void set_item(const affine_bg_item& item)
Replaces the tiles, the color palette and the map used by this affine background with the created with the given affine_bg_item.
void set_item(const affine_bg_item& item, int map_index)
Replaces the tiles, the color palette and the map used by this affine background with the created with the given affine_bg_item.
auto x() const -> fixed
Returns the horizontal position of the affine background (relative to its camera, if it has one).
void set_x(fixed x)
Sets the horizontal position of the affine background (relative to its camera, if it has one).
auto y() const -> fixed
Returns the vertical position of the affine background (relative to its camera, if it has one).
void set_y(fixed y)
Sets the vertical position of the affine background (relative to its camera, if it has one).
auto position() const -> const fixed_point&
Returns the position of the affine background (relative to its camera, if it has one).
void set_position(fixed x, fixed y)
Sets the position of the affine background (relative to its camera, if it has one).
void set_position(const fixed_point& position)
Sets the position of the affine background (relative to its camera, if it has one).
auto top_left_x() const -> fixed
Returns the horizontal top-left position of the affine background (relative to its camera, if it has one).
void set_top_left_x(fixed top_left_x)
Sets the horizontal top-left position of the affine background (relative to its camera, if it has one).
auto top_left_y() const -> fixed
Returns the vertical top-left position of the affine background (relative to its camera, if it has one).
void set_top_left_y(fixed top_left_y)
Sets the vertical top-left position of the affine background (relative to its camera, if it has one).
auto top_left_position() const -> fixed_point
Returns the top-left position of the affine background (relative to its camera, if it has one).
void set_top_left_position(fixed top_left_x, fixed top_left_y)
Sets the top-left position of the affine background (relative to its camera, if it has one).
void set_top_left_position(const fixed_point& top_left_position)
Sets the top-left position of the affine background (relative to its camera, if it has one).
auto rotation_angle() const -> fixed
Returns the rotation angle in degrees of the affine background.
void set_rotation_angle(fixed rotation_angle)
Sets the rotation angle in degrees of the affine background.
void set_rotation_angle_safe(fixed rotation_angle)
Sets the rotation angle in degrees of the affine background.
auto horizontal_scale() const -> fixed
Returns the horizontal scale of the affine background.
void set_horizontal_scale(fixed horizontal_scale)
Sets the horizontal scale of the affine background.
auto vertical_scale() const -> fixed
Returns the vertical scale of the affine background.
void set_vertical_scale(fixed vertical_scale)
Sets the vertical scale of the affine background.
void set_scale(fixed scale)
Sets the scale of the affine background.
void set_scale(fixed horizontal_scale, fixed vertical_scale)
Sets the scale of the affine background.
auto horizontal_shear() const -> fixed
Returns the horizontal shear of the affine background.
void set_horizontal_shear(fixed horizontal_shear)
Sets the horizontal shear of the affine background.
auto vertical_shear() const -> fixed
Returns the vertical shear of the affine background.
void set_vertical_shear(fixed vertical_shear)
Sets the vertical shear of the affine background.
void set_shear(fixed shear)
Sets the shear of the affine background.
void set_shear(fixed horizontal_shear, fixed vertical_shear)
Sets the shear of the affine background.
auto horizontal_flip() const -> bool
Indicates if this affine background is flipped in the horizontal axis or not.
void set_horizontal_flip(bool horizontal_flip)
Sets if this affine background must be flipped in the horizontal axis or not.
auto vertical_flip() const -> bool
Indicates if this affine background must be flipped in the vertical axis or not.
void set_vertical_flip(bool vertical_flip)
Sets if this affine background must be flipped in the vertical axis or not.
auto pivot_x() const -> fixed
Returns the horizontal position of the affine transformations pivot point of this affine background.
void set_pivot_x(fixed pivot_x)
Sets the horizontal position of the affine transformations pivot point of this affine background.
auto pivot_y() const -> fixed
Returns the vertical position of the affine transformations pivot point of this affine background.
void set_pivot_y(fixed pivot_y)
Sets the vertical position of the affine transformations pivot point of this affine background.
auto pivot_position() const -> const fixed_point&
Returns the position of the affine transformations pivot point of this affine background.
void set_pivot_position(fixed pivot_x, fixed pivot_y)
Sets the position of the affine transformations pivot point of this affine background.
void set_pivot_position(const fixed_point& pivot_position)
Sets the position of the affine transformations pivot point of this affine background.
auto mat_attributes() const -> const affine_bg_mat_attributes&
Returns the attributes of the position and the transformation matrix of this affine background.
void set_mat_attributes(const affine_mat_attributes& mat_attributes)
Sets the attributes of the affine transformation matrix of this affine background.
auto priority() const -> int
Returns the priority of the affine background relative to sprites and other backgrounds.
void set_priority(int priority)
Sets the priority of the affine background relative to sprites and other backgrounds.
auto z_order() const -> int
Returns the priority of the affine background relative to other backgrounds, excluding sprites.
void set_z_order(int z_order)
Sets the priority of the affine background relative to other backgrounds, excluding sprites.
void put_above()
Modify this affine background to be drawn above all of the other backgrounds with the same priority.
void put_below()
Modify this affine background to be drawn below all of the other backgrounds with the same priority.
auto wrapping_enabled() const -> bool
Indicates if this affine background wraps around at the edges or not.
void set_wrapping_enabled(bool wrapping_enabled)
Sets if this affine background must wrap around at the edges or not.
auto mosaic_enabled() const -> bool
Indicates if the mosaic effect must be applied to this affine background or not.
void set_mosaic_enabled(bool mosaic_enabled)
Sets if the mosaic effect must be applied to this affine background or not.
auto blending_enabled() const -> bool
Indicates if blending must be applied to this affine background or not.
void set_blending_enabled(bool blending_enabled)
Sets if blending must be applied to this affine background or not.
auto blending_top_enabled() const -> bool
Indicates if this affine background is part of the blending top layer or not.
void set_blending_top_enabled(bool blending_top_enabled)
Sets if this affine background is part of the blending top layer or not.
auto blending_bottom_enabled() const -> bool
Indicates if this affine background is part of the blending bottom layer or not.
void set_blending_bottom_enabled(bool blending_bottom_enabled)
Sets if this affine background is part of the blending bottom layer or not.
auto visible() const -> bool
Indicates if this affine background must be committed to the GBA or not.
void set_visible(bool visible)
Sets if this affine background must be committed to the GBA or not.
auto visible_in_window(const window& window) const -> bool
Indicates if this affine background is visible in the given window or not.
void set_visible_in_window(bool visible, window& window)
Sets if this affine background must be visible in the given window or not.
auto camera() const -> const optional<camera_ptr>&
Returns the camera_ptr attached to this affine background (if any).
void set_camera(const camera_ptr& camera)
Sets the camera_ptr attached to this affine background.
void set_camera(camera_ptr&& camera)
Sets the camera_ptr attached to this affine background.
void set_camera(const optional<camera_ptr>& camera)
Sets or removes the camera_ptr attached to this affine background.
void set_camera(optional<camera_ptr>&& camera)
Sets or removes the camera_ptr attached to this affine background.
void remove_camera()
Removes the camera_ptr attached to this affine background (if any).
auto attributes() const -> affine_bg_attributes
Returns the attributes to commit to the GBA for this affine background.
void set_attributes(const affine_bg_attributes& attributes)
Sets the attributes to commit to the GBA for this affine background.
auto hw_id() const -> optional<int>
Returns the hardware ID assigned to this background or bn::nullopt if no hardware ID has been assigned.
auto handle() const -> const void*
Returns the internal handle.
void swap(affine_bg_ptr& other)
Exchanges the contents of this affine_bg_ptr with those of the other one.

Friends

void swap(affine_bg_ptr& a, affine_bg_ptr& b)
Exchanges the contents of an affine_bg_ptr with those of another one.
auto operator==(const affine_bg_ptr& a, const affine_bg_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static affine_bg_ptr bn::affine_bg_ptr::create(const affine_bg_item& item)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
item affine_bg_item containing the required information to generate the affine background.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(const affine_bg_item& item, int map_index)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
item affine_bg_item containing the required information to generate the affine background.
map_index Index of the map to reference in item.map_item().
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(affine_bg_map_ptr map)

Creates an affine_bg_ptr from the given affine_bg_map_ptr.

Parameters
map affine_bg_map_ptr used by the affine background.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(fixed x, fixed y, const affine_bg_item& item)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(fixed x, fixed y, const affine_bg_item& item, int map_index)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
map_index Index of the map to reference in item.map_item().
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(const fixed_point& position, const affine_bg_item& item)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
position Position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(const fixed_point& position, const affine_bg_item& item, int map_index)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
position Position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
map_index Index of the map to reference in item.map_item().
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(fixed x, fixed y, affine_bg_map_ptr map)

Creates an affine_bg_ptr from the given affine_bg_map_ptr.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
map affine_bg_map_ptr used by the affine background.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(const fixed_point& position, affine_bg_map_ptr map)

Creates an affine_bg_ptr from the given affine_bg_map_ptr.

Parameters
position Position of the affine background.
map affine_bg_map_ptr used by the affine background.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(const affine_bg_builder& builder)

Creates an affine_bg_ptr from an affine_bg_builder reference.

Parameters
builder affine_bg_builder reference.
Returns The requested affine_bg_ptr.

static affine_bg_ptr bn::affine_bg_ptr::create(affine_bg_builder&& builder)

Creates an affine_bg_ptr from a moved affine_bg_builder.

Parameters
builder affine_bg_builder to move.
Returns The requested affine_bg_ptr.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(const affine_bg_item& item)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
item affine_bg_item containing the required information to generate the affine background.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(const affine_bg_item& item, int map_index)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
item affine_bg_item containing the required information to generate the affine background.
map_index Index of the map to reference in item.map_item().
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(affine_bg_map_ptr map)

Creates an affine_bg_ptr from the given affine_bg_map_ptr.

Parameters
map affine_bg_map_ptr used by the affine background.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(fixed x, fixed y, const affine_bg_item& item)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(fixed x, fixed y, const affine_bg_item& item, int map_index)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
map_index Index of the map to reference in item.map_item().
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(const fixed_point& position, const affine_bg_item& item)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
position Position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(const fixed_point& position, const affine_bg_item& item, int map_index)

Creates an affine_bg_ptr from the given affine_bg_item.

Parameters
position Position of the affine background.
item affine_bg_item containing the required information to generate the affine background.
map_index Index of the map to reference in item.map_item().
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(fixed x, fixed y, affine_bg_map_ptr map)

Creates an affine_bg_ptr from the given affine_bg_map_ptr.

Parameters
x Horizontal position of the affine background.
y Vertical position of the affine background.
map affine_bg_map_ptr used by the affine background.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(const fixed_point& position, affine_bg_map_ptr map)

Creates an affine_bg_ptr from the given affine_bg_map_ptr.

Parameters
position Position of the affine background.
map affine_bg_map_ptr used by the affine background.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(const affine_bg_builder& builder)

Creates an affine_bg_ptr from an affine_bg_builder reference.

Parameters
builder affine_bg_builder reference.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

static optional<affine_bg_ptr> bn::affine_bg_ptr::create_optional(affine_bg_builder&& builder)

Creates an affine_bg_ptr from a moved affine_bg_builder.

Parameters
builder affine_bg_builder to move.
Returns The requested affine_bg_ptr if it could be allocated; bn::nullopt otherwise.

bn::affine_bg_ptr::affine_bg_ptr(const affine_bg_ptr& other)

Copy constructor.

Parameters
other affine_bg_ptr to copy.

bn::affine_bg_ptr::affine_bg_ptr(affine_bg_ptr&& other) noexcept

Move constructor.

Parameters
other affine_bg_ptr to move.

affine_bg_ptr& bn::affine_bg_ptr::operator=(const affine_bg_ptr& other)

Copy assignment operator.

Parameters
other affine_bg_ptr to copy.
Returns Reference to this.

affine_bg_ptr& bn::affine_bg_ptr::operator=(affine_bg_ptr&& other) noexcept

Move assignment operator.

Parameters
other affine_bg_ptr to move.
Returns Reference to this.

bool bn::affine_bg_ptr::big() const

Indicates if this affine background is big or not.

Big backgrounds are slower CPU wise, but can have any width or height multiple of 256 pixels.

void bn::affine_bg_ptr::set_tiles(const affine_bg_tiles_ptr& tiles)

Sets the tiles used by this affine background.

Parameters
tiles affine_bg_tiles_ptr to copy.

It must be compatible with the current map of the affine background.

void bn::affine_bg_ptr::set_tiles(affine_bg_tiles_ptr&& tiles)

Sets the tiles used by this affine background.

Parameters
tiles affine_bg_tiles_ptr to move.

It must be compatible with the current map of the affine background.

void bn::affine_bg_ptr::set_tiles(const affine_bg_tiles_item& tiles_item)

Replaces the tiles used by this affine background with a new tile set created with the given affine_bg_tiles_item.

Parameters
tiles_item It creates the new background tiles to use by this affine background.

Before creating a new background tile set, the affine_bg_tiles_ptr used by this affine background is removed, so VRAM usage is reduced.

The new background tiles must be compatible with the current map of the affine background.

void bn::affine_bg_ptr::set_palette(const bg_palette_ptr& palette)

Sets the color palette to use by this affine background.

Parameters
palette bg_palette_ptr to copy.

void bn::affine_bg_ptr::set_palette(bg_palette_ptr&& palette)

Sets the color palette to use by this affine background.

Parameters
palette bg_palette_ptr to move.

void bn::affine_bg_ptr::set_palette(const bg_palette_item& palette_item)

Replaces the color palette used by this affine background with a new one created with the given bg_palette_item.

Parameters
palette_item It creates the color palette to use by this affine background.

Before creating a new color palette, the bg_palette_ptr used by this affine background is removed, so VRAM usage is reduced.

void bn::affine_bg_ptr::set_map(const affine_bg_map_ptr& map)

Sets the map used by this affine background.

Parameters
map affine_bg_map_ptr to copy.

void bn::affine_bg_ptr::set_map(affine_bg_map_ptr&& map)

Sets the map used by this affine background.

Parameters
map affine_bg_map_ptr to move.

void bn::affine_bg_ptr::set_map(const affine_bg_map_item& map_item)

Replaces the map used by this affine background with a new map created with the given affine_bg_map_item.

Parameters
map_item It creates the new map to use by this affine background.

Before creating a new map, the affine_bg_map_ptr used by this affine background is removed, so VRAM usage is reduced.

void bn::affine_bg_ptr::set_map(const affine_bg_map_item& map_item, int map_index)

Replaces the map used by this affine background with a new map created with the given affine_bg_map_item.

Parameters
map_item It creates the new map to use by this affine background.
map_index Index of the map to reference in map_item.

Before creating a new map, the affine_bg_map_ptr used by this affine background is removed, so VRAM usage is reduced.

void bn::affine_bg_ptr::set_item(const affine_bg_item& item)

Replaces the tiles, the color palette and the map used by this affine background with the created with the given affine_bg_item.

Parameters
item It creates the resources to use by this affine background.

Before creating new resources, the resources used by this affine background are removed, so VRAM usage is reduced.

void bn::affine_bg_ptr::set_item(const affine_bg_item& item, int map_index)

Replaces the tiles, the color palette and the map used by this affine background with the created with the given affine_bg_item.

Parameters
item It creates the resources to use by this affine background.
map_index Index of the map to reference in item.map_item().

Before creating new resources, the resources used by this affine background are removed, so VRAM usage is reduced.

void bn::affine_bg_ptr::set_position(fixed x, fixed y)

Sets the position of the affine background (relative to its camera, if it has one).

Parameters
x Horizontal position of the affine background (relative to its camera, if it has one).
y Vertical position of the affine background (relative to its camera, if it has one).

void bn::affine_bg_ptr::set_top_left_position(fixed top_left_x, fixed top_left_y)

Sets the top-left position of the affine background (relative to its camera, if it has one).

Parameters
top_left_x Horizontal top-left position of the affine background (relative to its camera, if it has one).
top_left_y Vertical top-left position of the affine background (relative to its camera, if it has one).

void bn::affine_bg_ptr::set_rotation_angle(fixed rotation_angle)

Sets the rotation angle in degrees of the affine background.

Parameters
rotation_angle Rotation angle in degrees, in the range [0..360].

void bn::affine_bg_ptr::set_rotation_angle_safe(fixed rotation_angle)

Sets the rotation angle in degrees of the affine background.

Parameters
rotation_angle Rotation angle in degrees, in any range.

void bn::affine_bg_ptr::set_scale(fixed horizontal_scale, fixed vertical_scale)

Sets the scale of the affine background.

Parameters
horizontal_scale Horizontal scale.
vertical_scale Vertical scale.

void bn::affine_bg_ptr::set_shear(fixed horizontal_shear, fixed vertical_shear)

Sets the shear of the affine background.

Parameters
horizontal_shear Horizontal shear.
vertical_shear Vertical shear.

void bn::affine_bg_ptr::set_pivot_position(fixed pivot_x, fixed pivot_y)

Sets the position of the affine transformations pivot point of this affine background.

Parameters
pivot_x Horizontal position of the pivot point.
pivot_y Vertical position of the pivot point.

void bn::affine_bg_ptr::set_pivot_position(const fixed_point& pivot_position)

Sets the position of the affine transformations pivot point of this affine background.

Parameters
pivot_position Position of the pivot point.

int bn::affine_bg_ptr::priority() const

Returns the priority of the affine background relative to sprites and other backgrounds.

Backgrounds with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds).

void bn::affine_bg_ptr::set_priority(int priority)

Sets the priority of the affine background relative to sprites and other backgrounds.

Parameters
priority Priority in the range [0..3].

Backgrounds with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds).

int bn::affine_bg_ptr::z_order() const

Returns the priority of the affine background relative to other backgrounds, excluding sprites.

Backgrounds with higher z orders are drawn first (and therefore can be covered by later backgrounds).

Due to hardware limitations, affine backgrounds can be drawn before regular backgrounds with higher z order.

void bn::affine_bg_ptr::set_z_order(int z_order)

Sets the priority of the affine background relative to other backgrounds, excluding sprites.

Parameters
z_order Priority relative to other backgrounds, excluding sprites, in the range [-32767..32767].

Backgrounds with higher z orders are drawn first (and therefore can be covered by later backgrounds).

Due to hardware limitations, affine backgrounds can be drawn before regular backgrounds with higher z order.

bool bn::affine_bg_ptr::blending_enabled() const

Indicates if blending must be applied to this affine background or not.

Blending is applied to this affine background by making it part of the blending top layer.

void bn::affine_bg_ptr::set_blending_enabled(bool blending_enabled)

Sets if blending must be applied to this affine background or not.

Blending is applied to this affine background by making it part of the blending top layer.

void bn::affine_bg_ptr::set_camera(const camera_ptr& camera)

Sets the camera_ptr attached to this affine background.

Parameters
camera camera_ptr to copy to this affine background.

void bn::affine_bg_ptr::set_camera(camera_ptr&& camera)

Sets the camera_ptr attached to this affine background.

Parameters
camera camera_ptr to move to this affine background.

void bn::affine_bg_ptr::set_camera(const optional<camera_ptr>& camera)

Sets or removes the camera_ptr attached to this affine background.

Parameters
camera Optional camera_ptr to copy to this affine background.

void bn::affine_bg_ptr::set_camera(optional<camera_ptr>&& camera)

Sets or removes the camera_ptr attached to this affine background.

Parameters
camera Optional camera_ptr to move to this affine background.

optional<int> bn::affine_bg_ptr::hw_id() const

Returns the hardware ID assigned to this background or bn::nullopt if no hardware ID has been assigned.

Normally you should not need to call this function, but it can be useful for messing with HDMA for example.

A background doesn't have an assigned hardware ID if it is not visible.

Assigned hardware ID can change after calling this method if some properties of this background or others are updated.

Call this method at your own risk.

void bn::affine_bg_ptr::swap(affine_bg_ptr& other)

Exchanges the contents of this affine_bg_ptr with those of the other one.

Parameters
other affine_bg_ptr to exchange the contents with.

void swap(affine_bg_ptr& a, affine_bg_ptr& b)

Exchanges the contents of an affine_bg_ptr with those of another one.

Parameters
a First affine_bg_ptr to exchange the contents with.
b Second affine_bg_ptr to exchange the contents with.