improve the migration

This commit is contained in:
Corwin 2023-04-05 18:35:45 +01:00
parent 78eebdd270
commit c84e81299b
No known key found for this signature in database
14 changed files with 172 additions and 179 deletions

View file

@ -4,7 +4,7 @@
use agb::{ use agb::{
display::tiled::{TileFormat, TileSet, TileSetting, TiledMap}, display::tiled::{TileFormat, TileSet, TileSetting, TiledMap},
display::{ display::{
object::{OamManager, Object, Size, Sprite}, object::{OamManaged, Object, Size, Sprite},
palette16::Palette16, palette16::Palette16,
tiled::RegularBackgroundSize, tiled::RegularBackgroundSize,
HEIGHT, WIDTH, HEIGHT, WIDTH,
@ -76,9 +76,9 @@ fn main(mut gba: agb::Gba) -> ! {
let object = gba.display.object.get_managed(); let object = gba.display.object.get_managed();
let sprite = object.get_vram_sprite(&CHICKEN_SPRITES[0]); let sprite = object.get_sprite(&CHICKEN_SPRITES[0]);
let mut chicken = Character { let mut chicken = Character {
object: object.add_object(sprite), object: object.object(sprite),
position: Vector2D { position: Vector2D {
x: (6 * 8) << 8, x: (6 * 8) << 8,
y: ((7 * 8) - 4) << 8, y: ((7 * 8) - 4) << 8,
@ -145,7 +145,7 @@ fn main(mut gba: agb::Gba) -> ! {
fn update_chicken_object( fn update_chicken_object(
chicken: &'_ mut Character<'_>, chicken: &'_ mut Character<'_>,
gfx: &OamManager, gfx: &OamManaged,
state: State, state: State,
frame_count: u32, frame_count: u32,
) { ) {
@ -158,19 +158,19 @@ fn update_chicken_object(
State::Ground => { State::Ground => {
if chicken.velocity.x.abs() > 1 << 4 { if chicken.velocity.x.abs() > 1 << 4 {
chicken.object.set_sprite( chicken.object.set_sprite(
gfx.get_vram_sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 1, 3, 10)]), gfx.get_sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 1, 3, 10)]),
); );
} else { } else {
chicken chicken
.object .object
.set_sprite(gfx.get_vram_sprite(&CHICKEN_SPRITES[0])); .set_sprite(gfx.get_sprite(&CHICKEN_SPRITES[0]));
} }
} }
State::Upwards => {} State::Upwards => {}
State::Flapping => { State::Flapping => {
chicken.object.set_sprite( chicken
gfx.get_vram_sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 4, 5, 5)]), .object
); .set_sprite(gfx.get_sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 4, 5, 5)]));
} }
} }

View file

@ -5,7 +5,7 @@ extern crate alloc;
use agb::display::{ use agb::display::{
affine::AffineMatrix, affine::AffineMatrix,
object::{self, Graphics, OamManager, Sprite, TagMap}, object::{self, Graphics, OamManaged, Sprite, TagMap},
}; };
use agb::fixnum::num; use agb::fixnum::num;
use agb_fixnum::Num; use agb_fixnum::Num;
@ -20,7 +20,7 @@ const GRAPHICS: &Graphics = agb::include_aseprite!(
const SPRITES: &[Sprite] = GRAPHICS.sprites(); const SPRITES: &[Sprite] = GRAPHICS.sprites();
const TAG_MAP: &TagMap = GRAPHICS.tags(); const TAG_MAP: &TagMap = GRAPHICS.tags();
fn all_sprites(gfx: &OamManager, rotation_speed: Num<i32, 16>) { fn all_sprites(gfx: &OamManaged, rotation_speed: Num<i32, 16>) {
let mut input = agb::input::ButtonController::new(); let mut input = agb::input::ButtonController::new();
let mut objs = Vec::new(); let mut objs = Vec::new();
@ -31,7 +31,7 @@ fn all_sprites(gfx: &OamManager, rotation_speed: Num<i32, 16>) {
for y in 0..9 { for y in 0..9 {
for x in 0..14 { for x in 0..14 {
let mut obj = gfx.add_object_static_sprite(&SPRITES[0]); let mut obj = gfx.object_sprite(&SPRITES[0]);
obj.set_affine_matrix(matrix.clone()); obj.set_affine_matrix(matrix.clone());
obj.show_affine(object::AffineMode::Affine); obj.show_affine(object::AffineMode::Affine);
obj.set_position((x * 16 + 8, y * 16 + 8).into()); obj.set_position((x * 16 + 8, y * 16 + 8).into());
@ -68,14 +68,14 @@ fn all_sprites(gfx: &OamManager, rotation_speed: Num<i32, 16>) {
image %= SPRITES.len(); image %= SPRITES.len();
for (i, obj) in objs.iter_mut().enumerate() { for (i, obj) in objs.iter_mut().enumerate() {
let this_image = (image + i) % SPRITES.len(); let this_image = (image + i) % SPRITES.len();
obj.set_sprite(gfx.get_vram_sprite(&SPRITES[this_image])); obj.set_sprite(gfx.get_sprite(&SPRITES[this_image]));
} }
} }
gfx.commit(); gfx.commit();
} }
} }
fn all_tags(gfx: &OamManager) { fn all_tags(gfx: &OamManaged) {
let mut input = agb::input::ButtonController::new(); let mut input = agb::input::ButtonController::new();
let mut objs = Vec::new(); let mut objs = Vec::new();
@ -85,7 +85,7 @@ fn all_tags(gfx: &OamManager) {
let sprite = v.sprite(0); let sprite = v.sprite(0);
let (size_x, size_y) = sprite.size().to_width_height(); let (size_x, size_y) = sprite.size().to_width_height();
let (size_x, size_y) = (size_x as i32, size_y as i32); let (size_x, size_y) = (size_x as i32, size_y as i32);
let mut obj = gfx.add_object_static_sprite(sprite); let mut obj = gfx.object_sprite(sprite);
obj.show(); obj.show();
obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2).into()); obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2).into());
objs.push((obj, v)); objs.push((obj, v));
@ -110,7 +110,7 @@ fn all_tags(gfx: &OamManager) {
if count % 5 == 0 { if count % 5 == 0 {
image += 1; image += 1;
for (obj, tag) in objs.iter_mut() { for (obj, tag) in objs.iter_mut() {
obj.set_sprite(gfx.get_vram_sprite(tag.animation_sprite(image))); obj.set_sprite(gfx.get_sprite(tag.animation_sprite(image)));
} }
gfx.commit(); gfx.commit();
} }

View file

@ -6,7 +6,7 @@ use video::Video;
use self::{ use self::{
blend::Blend, blend::Blend,
object::{initilise_oam, OamManager, OamUnmanaged, SpriteLoader}, object::{initilise_oam, OamManaged, OamUnmanaged, SpriteLoader},
window::Windows, window::Windows,
}; };
@ -89,9 +89,9 @@ impl ObjectDistribution {
(OamUnmanaged::new(), SpriteLoader::new()) (OamUnmanaged::new(), SpriteLoader::new())
} }
pub fn get_managed(&mut self) -> OamManager<'_> { pub fn get_managed(&mut self) -> OamManaged<'_> {
unsafe { initilise_oam() }; unsafe { initilise_oam() };
OamManager::new() OamManaged::new()
} }
} }

View file

@ -8,7 +8,7 @@ pub use sprites::{
}; };
pub use affine::AffineMatrixInstance; pub use affine::AffineMatrixInstance;
pub use managed::{OamManager, Object}; pub use managed::{OamManaged, Object};
pub use unmanaged::{AffineMode, OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged}; pub use unmanaged::{AffineMode, OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged};
use super::DISPLAY_CONTROL; use super::DISPLAY_CONTROL;

View file

@ -125,13 +125,13 @@ impl Store {
} }
} }
pub struct OamManager<'gba> { pub struct OamManaged<'gba> {
object_store: Store, object_store: Store,
sprite_loader: UnsafeCell<SpriteLoader>, sprite_loader: UnsafeCell<SpriteLoader>,
unmanaged: UnsafeCell<OamUnmanaged<'gba>>, unmanaged: UnsafeCell<OamUnmanaged<'gba>>,
} }
impl OamManager<'_> { impl OamManaged<'_> {
pub(crate) fn new() -> Self { pub(crate) fn new() -> Self {
Self { Self {
object_store: Store { object_store: Store {
@ -172,20 +172,20 @@ impl OamManager<'_> {
} }
} }
pub fn add_object(&self, sprite: SpriteVram) -> Object<'_> { pub fn object(&self, sprite: SpriteVram) -> Object<'_> {
self.object_store self.object_store
.insert_object(ObjectUnmanaged::new(sprite)) .insert_object(ObjectUnmanaged::new(sprite))
} }
pub fn get_vram_sprite(&self, sprite: &'static Sprite) -> SpriteVram { pub fn get_sprite(&self, sprite: &'static Sprite) -> SpriteVram {
// safety: not reentrant // safety: not reentrant
unsafe { unsafe {
self.do_work_with_sprite_loader(|sprite_loader| sprite_loader.get_vram_sprite(sprite)) self.do_work_with_sprite_loader(|sprite_loader| sprite_loader.get_vram_sprite(sprite))
} }
} }
pub fn add_object_static_sprite(&self, sprite: &'static Sprite) -> Object<'_> { pub fn object_sprite(&self, sprite: &'static Sprite) -> Object<'_> {
self.add_object(self.get_vram_sprite(sprite)) self.object(self.get_sprite(sprite))
} }
} }
@ -449,11 +449,11 @@ mod tests {
fn test_always_ordered(gba: &mut crate::Gba) { fn test_always_ordered(gba: &mut crate::Gba) {
let managed = gba.display.object.get_managed(); let managed = gba.display.object.get_managed();
let sprite = managed.get_vram_sprite(TEST_SPRITE); let sprite = managed.get_sprite(TEST_SPRITE);
let mut objects = Vec::new(); let mut objects = Vec::new();
for _ in 0..200 { for _ in 0..200 {
let obj = managed.add_object(sprite.clone()); let obj = managed.object(sprite.clone());
objects.push(obj); objects.push(obj);
} }

View file

@ -32,7 +32,7 @@ const BALL: &Tag = GRAPHICS.tags().get("Ball");
#[agb::entry] #[agb::entry]
fn main(mut gba: agb::Gba) -> ! { fn main(mut gba: agb::Gba) -> ! {
// Get the OAM manager // Get the OAM manager
let object = gba.display.object.get(); let object = gba.display.object.get_managed();
// Create an object with the ball sprite // Create an object with the ball sprite
let mut ball = object.object_sprite(BALL.sprite(0)); let mut ball = object.object_sprite(BALL.sprite(0));

View file

@ -494,7 +494,7 @@ pub(crate) fn battle_screen(
let obj = &agb.obj; let obj = &agb.obj;
let mut select_box_obj = agb.obj.add_object_static_sprite(SELECT_BOX.sprite(0)); let mut select_box_obj = agb.obj.object_sprite(SELECT_BOX.sprite(0));
select_box_obj.show(); select_box_obj.show();
let num_dice = player_dice.dice.len(); let num_dice = player_dice.dice.len();
@ -587,7 +587,7 @@ pub(crate) fn battle_screen(
.set_x(selected_die as u16 * 40 + 28 - 4) .set_x(selected_die as u16 * 40 + 28 - 4)
.set_sprite( .set_sprite(
agb.obj agb.obj
.get_vram_sprite(SELECT_BOX.animation_sprite(counter / 10)), .get_sprite(SELECT_BOX.animation_sprite(counter / 10)),
); );
agb.star_background.update(); agb.star_background.update();

View file

@ -1,4 +1,4 @@
use agb::display::object::{OamManager, Object}; use agb::display::object::{OamManaged, Object};
use agb::rng; use agb::rng;
use alloc::vec; use alloc::vec;
use alloc::vec::Vec; use alloc::vec::Vec;
@ -39,7 +39,7 @@ pub struct BattleScreenDisplay<'a> {
const HEALTH_BAR_WIDTH: usize = 48; const HEALTH_BAR_WIDTH: usize = 48;
impl<'a> BattleScreenDisplay<'a> { impl<'a> BattleScreenDisplay<'a> {
pub fn new(obj: &'a OamManager, current_battle_state: &CurrentBattleState) -> Self { pub fn new(obj: &'a OamManaged, current_battle_state: &CurrentBattleState) -> Self {
let mut misc_sprites = vec![]; let mut misc_sprites = vec![];
let player_x = 12; let player_x = 12;
let player_y = 8; let player_y = 8;
@ -52,8 +52,8 @@ impl<'a> BattleScreenDisplay<'a> {
Ship::PilotedShip Ship::PilotedShip
}); });
let mut player_obj = obj.add_object_static_sprite(player_sprite); let mut player_obj = obj.object_sprite(player_sprite);
let mut enemy_obj = obj.add_object_static_sprite(enemy_sprite); let mut enemy_obj = obj.object_sprite(enemy_sprite);
player_obj.set_x(player_x).set_y(player_y).set_z(1).show(); player_obj.set_x(player_x).set_y(player_y).set_z(1).show();
enemy_obj.set_x(enemy_x).set_y(player_y).set_z(1).show(); enemy_obj.set_x(enemy_x).set_y(player_y).set_z(1).show();
@ -66,7 +66,7 @@ impl<'a> BattleScreenDisplay<'a> {
.faces_to_render() .faces_to_render()
.enumerate() .enumerate()
.map(|(i, (face, _))| { .map(|(i, (face, _))| {
let mut die_obj = obj.add_object_static_sprite(FACE_SPRITES.sprite_for_face(face)); let mut die_obj = obj.object_sprite(FACE_SPRITES.sprite_for_face(face));
die_obj.set_y(120).set_x(i as u16 * 40 + 28).show(); die_obj.set_y(120).set_x(i as u16 * 40 + 28).show();
@ -89,7 +89,7 @@ impl<'a> BattleScreenDisplay<'a> {
let player_shield: Vec<_> = (0..5) let player_shield: Vec<_> = (0..5)
.map(|i| { .map(|i| {
let mut shield_obj = obj.add_object_static_sprite(shield_sprite); let mut shield_obj = obj.object_sprite(shield_sprite);
shield_obj shield_obj
.set_x(player_x + 18 + 11 * i) .set_x(player_x + 18 + 11 * i)
.set_y(player_y) .set_y(player_y)
@ -101,7 +101,7 @@ impl<'a> BattleScreenDisplay<'a> {
let enemy_shield: Vec<_> = (0..5) let enemy_shield: Vec<_> = (0..5)
.map(|i| { .map(|i| {
let mut shield_obj = obj.add_object_static_sprite(shield_sprite); let mut shield_obj = obj.object_sprite(shield_sprite);
shield_obj shield_obj
.set_x(enemy_x - 16 - 11 * i) .set_x(enemy_x - 16 - 11 * i)
.set_y(player_y) .set_y(player_y)
@ -146,9 +146,8 @@ impl<'a> BattleScreenDisplay<'a> {
let enemy_attack_display = (0..2) let enemy_attack_display = (0..2)
.map(|i| { .map(|i| {
let mut attack_obj = obj.add_object_static_sprite( let mut attack_obj = obj
ENEMY_ATTACK_SPRITES.sprite_for_attack(EnemyAttackType::Attack), .object_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(EnemyAttackType::Attack));
);
let attack_obj_position = (120, 56 + 32 * i).into(); let attack_obj_position = (120, 56 + 32 * i).into();
attack_obj.set_position(attack_obj_position).hide(); attack_obj.set_position(attack_obj_position).hide();
@ -189,14 +188,14 @@ impl<'a> BattleScreenDisplay<'a> {
pub fn update( pub fn update(
&mut self, &mut self,
obj: &'a OamManager, obj: &'a OamManaged,
current_battle_state: &CurrentBattleState, current_battle_state: &CurrentBattleState,
) -> Vec<Action> { ) -> Vec<Action> {
for (i, player_shield) in self.objs.player_shield.iter_mut().enumerate() { for (i, player_shield) in self.objs.player_shield.iter_mut().enumerate() {
if i < current_battle_state.player.shield_count as usize { if i < current_battle_state.player.shield_count as usize {
player_shield player_shield
.show() .show()
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(0))); .set_sprite(obj.get_sprite(SHIELD.sprite(0)));
} else { } else {
player_shield.hide(); player_shield.hide();
} }
@ -206,7 +205,7 @@ impl<'a> BattleScreenDisplay<'a> {
if i < current_battle_state.enemy.shield_count as usize { if i < current_battle_state.enemy.shield_count as usize {
player_shield player_shield
.show() .show()
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(0))); .set_sprite(obj.get_sprite(SHIELD.sprite(0)));
} else { } else {
player_shield.hide(); player_shield.hide();
} }
@ -250,7 +249,7 @@ impl<'a> BattleScreenDisplay<'a> {
.zip(current_battle_state.rolled_dice.faces_to_render()) .zip(current_battle_state.rolled_dice.faces_to_render())
.zip(self.objs.dice_cooldowns.iter_mut()) .zip(self.objs.dice_cooldowns.iter_mut())
{ {
die_obj.set_sprite(obj.get_vram_sprite(FACE_SPRITES.sprite_for_face(current_face))); die_obj.set_sprite(obj.get_sprite(FACE_SPRITES.sprite_for_face(current_face)));
if let Some(cooldown) = cooldown { if let Some(cooldown) = cooldown {
cooldown_healthbar cooldown_healthbar
@ -279,7 +278,7 @@ impl<'a> BattleScreenDisplay<'a> {
actions_to_apply actions_to_apply
} }
pub fn add_action(&mut self, action: Action, obj: &'a OamManager, sfx: &mut Sfx) { pub fn add_action(&mut self, action: Action, obj: &'a OamManaged, sfx: &mut Sfx) {
play_sound_for_action_start(&action, sfx); play_sound_for_action_start(&action, sfx);
self.animations self.animations
@ -309,10 +308,10 @@ impl<'a> EnemyAttackDisplay<'a> {
} }
} }
pub fn update(&mut self, attack: &Option<EnemyAttackState>, obj: &'a OamManager) { pub fn update(&mut self, attack: &Option<EnemyAttackState>, obj: &'a OamManaged) {
if let Some(attack) = attack { if let Some(attack) = attack {
self.face.show().set_sprite( self.face.show().set_sprite(
obj.get_vram_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(attack.attack_type())), obj.get_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(attack.attack_type())),
); );
self.cooldown self.cooldown
.set_value((attack.cooldown * 48 / attack.max_cooldown) as usize, obj); .set_value((attack.cooldown * 48 / attack.max_cooldown) as usize, obj);
@ -350,27 +349,27 @@ enum AnimationUpdateState {
} }
impl<'a> AnimationStateHolder<'a> { impl<'a> AnimationStateHolder<'a> {
fn for_action(a: Action, obj: &'a OamManager) -> Self { fn for_action(a: Action, obj: &'a OamManaged) -> Self {
let state = match a { let state = match a {
Action::PlayerActivateShield { amount, .. } => { Action::PlayerActivateShield { amount, .. } => {
AnimationState::PlayerActivateShield { amount, frame: 0 } AnimationState::PlayerActivateShield { amount, frame: 0 }
} }
Action::PlayerShoot { .. } => AnimationState::PlayerShoot { Action::PlayerShoot { .. } => AnimationState::PlayerShoot {
bullet: obj.add_object_static_sprite(BULLET_SPRITE), bullet: obj.object_sprite(BULLET_SPRITE),
x: 64, x: 64,
}, },
Action::PlayerDisrupt { .. } => AnimationState::PlayerDisrupt { Action::PlayerDisrupt { .. } => AnimationState::PlayerDisrupt {
bullet: obj.add_object_static_sprite(DISRUPT_BULLET), bullet: obj.object_sprite(DISRUPT_BULLET),
x: 64, x: 64,
}, },
Action::PlayerHeal { .. } => AnimationState::PlayerHeal {}, Action::PlayerHeal { .. } => AnimationState::PlayerHeal {},
Action::PlayerBurstShield { .. } => AnimationState::PlayerBurstShield { frame: 0 }, Action::PlayerBurstShield { .. } => AnimationState::PlayerBurstShield { frame: 0 },
Action::PlayerSendBurstShield { .. } => AnimationState::PlayerSendBurstShield { Action::PlayerSendBurstShield { .. } => AnimationState::PlayerSendBurstShield {
bullet: obj.add_object_static_sprite(BURST_BULLET), bullet: obj.object_sprite(BURST_BULLET),
x: 64, x: 64,
}, },
Action::EnemyShoot { .. } => AnimationState::EnemyShoot { Action::EnemyShoot { .. } => AnimationState::EnemyShoot {
bullet: obj.add_object_static_sprite(BULLET_SPRITE), bullet: obj.object_sprite(BULLET_SPRITE),
x: 175, x: 175,
}, },
Action::EnemyShield { amount, .. } => AnimationState::EnemyShield { amount, frame: 0 }, Action::EnemyShield { amount, .. } => AnimationState::EnemyShield { amount, frame: 0 },
@ -383,7 +382,7 @@ impl<'a> AnimationStateHolder<'a> {
fn update( fn update(
&mut self, &mut self,
objs: &mut BattleScreenDisplayObjects<'a>, objs: &mut BattleScreenDisplayObjects<'a>,
obj: &'a OamManager, obj: &'a OamManaged,
current_battle_state: &CurrentBattleState, current_battle_state: &CurrentBattleState,
) -> AnimationUpdateState { ) -> AnimationUpdateState {
match &mut self.state { match &mut self.state {
@ -414,7 +413,7 @@ impl<'a> AnimationStateHolder<'a> {
for i in current_player_shields..*amount { for i in current_player_shields..*amount {
objs.player_shield[i as usize] objs.player_shield[i as usize]
.show() .show()
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(3 - *frame / 2))); .set_sprite(obj.get_sprite(SHIELD.sprite(3 - *frame / 2)));
} }
} else { } else {
return AnimationUpdateState::RemoveWithAction(self.action.clone()); return AnimationUpdateState::RemoveWithAction(self.action.clone());
@ -445,7 +444,7 @@ impl<'a> AnimationStateHolder<'a> {
for i in current_enemy_shields..*amount { for i in current_enemy_shields..*amount {
objs.enemy_shield[i as usize] objs.enemy_shield[i as usize]
.show() .show()
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(3 - *frame / 2))); .set_sprite(obj.get_sprite(SHIELD.sprite(3 - *frame / 2)));
} }
} else { } else {
return AnimationUpdateState::RemoveWithAction(self.action.clone()); return AnimationUpdateState::RemoveWithAction(self.action.clone());
@ -468,7 +467,7 @@ impl<'a> AnimationStateHolder<'a> {
AnimationState::PlayerBurstShield { frame } => { AnimationState::PlayerBurstShield { frame } => {
if *frame < 10 { if *frame < 10 {
for shield in objs.player_shield.iter_mut() { for shield in objs.player_shield.iter_mut() {
shield.set_sprite(obj.get_vram_sprite(SHIELD.sprite(*frame / 2))); shield.set_sprite(obj.get_sprite(SHIELD.sprite(*frame / 2)));
} }
*frame += 1; *frame += 1;
@ -476,7 +475,7 @@ impl<'a> AnimationStateHolder<'a> {
AnimationUpdateState::Continue AnimationUpdateState::Continue
} else { } else {
for shield in objs.player_shield.iter_mut() { for shield in objs.player_shield.iter_mut() {
shield.set_sprite(obj.get_vram_sprite(SHIELD.sprite(0))); shield.set_sprite(obj.get_sprite(SHIELD.sprite(0)));
} }
AnimationUpdateState::RemoveWithAction(self.action.clone()) AnimationUpdateState::RemoveWithAction(self.action.clone())

View file

@ -1,6 +1,6 @@
use agb::{ use agb::{
display::{ display::{
object::{OamManager, Object}, object::{OamManaged, Object},
tiled::{RegularMap, TiledMap}, tiled::{RegularMap, TiledMap},
HEIGHT, WIDTH, HEIGHT, WIDTH,
}, },
@ -91,10 +91,10 @@ fn move_net_position_ud(idx: usize, direction: Tri) -> usize {
} }
} }
fn create_dice_display<'a>(gfx: &'a OamManager, dice: &'_ PlayerDice) -> Vec<Object<'a>> { fn create_dice_display<'a>(gfx: &'a OamManaged, dice: &'_ PlayerDice) -> Vec<Object<'a>> {
let mut objects = Vec::new(); let mut objects = Vec::new();
for (idx, dice) in dice.dice.iter().enumerate() { for (idx, dice) in dice.dice.iter().enumerate() {
let mut obj = gfx.add_object_static_sprite(FACE_SPRITES.sprite_for_face(dice.faces[1])); let mut obj = gfx.object_sprite(FACE_SPRITES.sprite_for_face(dice.faces[1]));
obj.set_x((idx as i32 * 32 - 24 / 2 + 20) as u16); obj.set_x((idx as i32 * 32 - 24 / 2 + 20) as u16);
obj.set_y(16 - 24 / 2); obj.set_y(16 - 24 / 2);
@ -105,10 +105,10 @@ fn create_dice_display<'a>(gfx: &'a OamManager, dice: &'_ PlayerDice) -> Vec<Obj
objects objects
} }
fn create_net<'a>(gfx: &'a OamManager, die: &'_ Die, modified: &[usize]) -> Vec<Object<'a>> { fn create_net<'a>(gfx: &'a OamManaged, die: &'_ Die, modified: &[usize]) -> Vec<Object<'a>> {
let mut objects = Vec::new(); let mut objects = Vec::new();
for (idx, &face) in die.faces.iter().enumerate() { for (idx, &face) in die.faces.iter().enumerate() {
let mut obj = gfx.add_object_static_sprite(FACE_SPRITES.sprite_for_face(face)); let mut obj = gfx.object_sprite(FACE_SPRITES.sprite_for_face(face));
let (x, y) = screen_position_for_index(idx); let (x, y) = screen_position_for_index(idx);
obj.set_x((x - 24 / 2) as u16); obj.set_x((x - 24 / 2) as u16);
obj.set_y((y - 24 / 2) as u16); obj.set_y((y - 24 / 2) as u16);
@ -119,7 +119,7 @@ fn create_net<'a>(gfx: &'a OamManager, die: &'_ Die, modified: &[usize]) -> Vec<
} }
for &m in modified.iter().chain(core::iter::once(&3)) { for &m in modified.iter().chain(core::iter::once(&3)) {
let mut obj = gfx.add_object_static_sprite(MODIFIED_BOX); let mut obj = gfx.object_sprite(MODIFIED_BOX);
let (x, y) = screen_position_for_index(m); let (x, y) = screen_position_for_index(m);
obj.set_x((x - 32 / 2) as u16); obj.set_x((x - 32 / 2) as u16);
obj.set_y((y - 32 / 2) as u16); obj.set_y((y - 32 / 2) as u16);
@ -139,10 +139,10 @@ fn upgrade_position(idx: usize) -> (u32, u32) {
) )
} }
fn create_upgrade_objects<'a>(gfx: &'a OamManager, upgrades: &[Face]) -> Vec<Object<'a>> { fn create_upgrade_objects<'a>(gfx: &'a OamManaged, upgrades: &[Face]) -> Vec<Object<'a>> {
let mut objects = Vec::new(); let mut objects = Vec::new();
for (idx, &upgrade) in upgrades.iter().enumerate() { for (idx, &upgrade) in upgrades.iter().enumerate() {
let mut obj = gfx.add_object_static_sprite(FACE_SPRITES.sprite_for_face(upgrade)); let mut obj = gfx.object_sprite(FACE_SPRITES.sprite_for_face(upgrade));
let (x, y) = upgrade_position(idx); let (x, y) = upgrade_position(idx);
obj.set_x((x - 24 / 2) as u16); obj.set_x((x - 24 / 2) as u16);
obj.set_y((y - 24 / 2) as u16); obj.set_y((y - 24 / 2) as u16);
@ -180,13 +180,13 @@ pub(crate) fn customise_screen(
let mut input = agb::input::ButtonController::new(); let mut input = agb::input::ButtonController::new();
let mut select_box = agb.obj.add_object_static_sprite(SELECT_BOX.sprite(0)); let mut select_box = agb.obj.object_sprite(SELECT_BOX.sprite(0));
select_box.show(); select_box.show();
let mut selected_dice = agb.obj.add_object_static_sprite(SELECTED_BOX); let mut selected_dice = agb.obj.object_sprite(SELECTED_BOX);
selected_dice.hide(); selected_dice.hide();
let mut selected_face = agb.obj.add_object_static_sprite(SELECTED_BOX); let mut selected_face = agb.obj.object_sprite(SELECTED_BOX);
selected_face.hide(); selected_face.hide();
agb.sfx.frame(); agb.sfx.frame();
@ -340,7 +340,7 @@ pub(crate) fn customise_screen(
select_box.set_sprite( select_box.set_sprite(
agb.obj agb.obj
.get_vram_sprite(SELECT_BOX.animation_sprite(counter / 10)), .get_sprite(SELECT_BOX.animation_sprite(counter / 10)),
); );
agb.star_background.update(); agb.star_background.update();

View file

@ -1,5 +1,5 @@
use agb::{ use agb::{
display::object::{OamManager, Object, Sprite, Tag}, display::object::{OamManaged, Object, Sprite, Tag},
fixnum::Vector2D, fixnum::Vector2D,
}; };
use alloc::vec::Vec; use alloc::vec::Vec;
@ -141,12 +141,12 @@ pub struct HealthBar<'a> {
} }
impl<'a> HealthBar<'a> { impl<'a> HealthBar<'a> {
pub fn new(pos: Vector2D<i32>, max: usize, obj: &'a OamManager) -> Self { pub fn new(pos: Vector2D<i32>, max: usize, obj: &'a OamManaged) -> Self {
assert_eq!(max % 8, 0); assert_eq!(max % 8, 0);
let sprites = (0..(max / 8)) let sprites = (0..(max / 8))
.map(|i| { .map(|i| {
let mut health_object = obj.add_object_static_sprite(SMALL_SPRITES.red_bar(0)); let mut health_object = obj.object_sprite(SMALL_SPRITES.red_bar(0));
health_object health_object
.set_position(pos + (i as i32 * 8, 0).into()) .set_position(pos + (i as i32 * 8, 0).into())
.show(); .show();
@ -157,18 +157,16 @@ impl<'a> HealthBar<'a> {
Self { max, sprites } Self { max, sprites }
} }
pub fn set_value(&mut self, new_value: usize, obj: &'a OamManager) { pub fn set_value(&mut self, new_value: usize, obj: &'a OamManaged) {
assert!(new_value <= self.max); assert!(new_value <= self.max);
for (i, sprite) in self.sprites.iter_mut().enumerate() { for (i, sprite) in self.sprites.iter_mut().enumerate() {
if (i + 1) * 8 < new_value { if (i + 1) * 8 < new_value {
sprite.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.red_bar(0))); sprite.set_sprite(obj.get_sprite(SMALL_SPRITES.red_bar(0)));
} else if i * 8 < new_value { } else if i * 8 < new_value {
sprite.set_sprite( sprite.set_sprite(obj.get_sprite(SMALL_SPRITES.red_bar(8 - (new_value - i * 8))));
obj.get_vram_sprite(SMALL_SPRITES.red_bar(8 - (new_value - i * 8))),
);
} else { } else {
sprite.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.red_bar(8))); sprite.set_sprite(obj.get_sprite(SMALL_SPRITES.red_bar(8)));
} }
} }
} }
@ -195,22 +193,22 @@ pub struct FractionDisplay<'a> {
} }
impl<'a> FractionDisplay<'a> { impl<'a> FractionDisplay<'a> {
pub fn new(pos: Vector2D<i32>, digits: usize, obj: &'a OamManager) -> Self { pub fn new(pos: Vector2D<i32>, digits: usize, obj: &'a OamManaged) -> Self {
let mut sprites = Vec::with_capacity(digits * 2 + 1); let mut sprites = Vec::with_capacity(digits * 2 + 1);
for i in 0..digits { for i in 0..digits {
let mut left_digit = obj.add_object_static_sprite(SMALL_SPRITES.number(0)); let mut left_digit = obj.object_sprite(SMALL_SPRITES.number(0));
left_digit.set_position(pos + (i as i32 * 4, 0).into()); left_digit.set_position(pos + (i as i32 * 4, 0).into());
sprites.push(left_digit); sprites.push(left_digit);
let mut right_digit = obj.add_object_static_sprite(SMALL_SPRITES.number(0)); let mut right_digit = obj.object_sprite(SMALL_SPRITES.number(0));
right_digit.set_position(pos + (i as i32 * 4 + digits as i32 * 4 + 7, 0).into()); right_digit.set_position(pos + (i as i32 * 4 + digits as i32 * 4 + 7, 0).into());
sprites.push(right_digit); sprites.push(right_digit);
} }
let mut slash = obj.add_object_static_sprite(SMALL_SPRITES.slash()); let mut slash = obj.object_sprite(SMALL_SPRITES.slash());
slash.set_position(pos + (digits as i32 * 4 + 1, 0).into()); slash.set_position(pos + (digits as i32 * 4 + 1, 0).into());
sprites.push(slash); sprites.push(slash);
@ -222,7 +220,7 @@ impl<'a> FractionDisplay<'a> {
} }
} }
pub fn set_value(&mut self, current: usize, max: usize, obj: &'a OamManager) { pub fn set_value(&mut self, current: usize, max: usize, obj: &'a OamManaged) {
if self.current_current == current && self.current_max == max { if self.current_current == current && self.current_max == max {
return; return;
} }
@ -235,13 +233,13 @@ impl<'a> FractionDisplay<'a> {
current /= 10; current /= 10;
let current_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 2]; let current_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 2];
current_value_sprite current_value_sprite
.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.number(current_value_digit as u32))); .set_sprite(obj.get_sprite(SMALL_SPRITES.number(current_value_digit as u32)));
let max_value_digit = max % 10; let max_value_digit = max % 10;
max /= 10; max /= 10;
let max_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 1]; let max_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 1];
max_value_sprite max_value_sprite
.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.number(max_value_digit as u32))); .set_sprite(obj.get_sprite(SMALL_SPRITES.number(max_value_digit as u32)));
} }
} }
} }
@ -261,7 +259,7 @@ impl<'a> NumberDisplay<'a> {
} }
} }
pub fn set_value(&mut self, new_value: Option<u32>, obj: &'a OamManager) { pub fn set_value(&mut self, new_value: Option<u32>, obj: &'a OamManaged) {
if self.value == new_value { if self.value == new_value {
return; return;
} }
@ -272,7 +270,7 @@ impl<'a> NumberDisplay<'a> {
if let Some(mut new_value) = new_value { if let Some(mut new_value) = new_value {
if new_value == 0 { if new_value == 0 {
let mut zero_object = obj.add_object_static_sprite(SMALL_SPRITES.number(0)); let mut zero_object = obj.object_sprite(SMALL_SPRITES.number(0));
zero_object.show().set_position(self.position); zero_object.show().set_position(self.position);
self.objects.push(zero_object); self.objects.push(zero_object);
@ -285,7 +283,7 @@ impl<'a> NumberDisplay<'a> {
new_value /= 10; new_value /= 10;
let mut current_value_obj = let mut current_value_obj =
obj.add_object_static_sprite(SMALL_SPRITES.number(current_value_digit)); obj.object_sprite(SMALL_SPRITES.number(current_value_digit));
current_value_obj current_value_obj
.show() .show()

View file

@ -12,7 +12,7 @@
#![cfg_attr(test, reexport_test_harness_main = "test_main")] #![cfg_attr(test, reexport_test_harness_main = "test_main")]
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))] #![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
use agb::display::object::OamManager; use agb::display::object::OamManaged;
use agb::display::tiled::{TileFormat, TiledMap, VRamManager}; use agb::display::tiled::{TileFormat, TiledMap, VRamManager};
use agb::display::Priority; use agb::display::Priority;
use agb::interrupt::VBlank; use agb::interrupt::VBlank;
@ -90,7 +90,7 @@ pub struct PlayerDice {
} }
struct Agb<'a> { struct Agb<'a> {
obj: OamManager<'a>, obj: OamManaged<'a>,
vblank: VBlank, vblank: VBlank,
star_background: StarBackground<'a>, star_background: StarBackground<'a>,
vram: VRamManager, vram: VRamManager,

View file

@ -2,7 +2,7 @@ use crate::TAG_MAP;
use super::{sfx::SfxPlayer, Entity, FixedNumberType, HatState, Level}; use super::{sfx::SfxPlayer, Entity, FixedNumberType, HatState, Level};
use agb::{ use agb::{
display::object::{OamManager, Tag}, display::object::{OamManaged, Tag},
fixnum::Vector2D, fixnum::Vector2D,
}; };
@ -35,11 +35,11 @@ pub enum EnemyUpdateState {
} }
impl<'a> Enemy<'a> { impl<'a> Enemy<'a> {
pub fn new_slime(object: &'a OamManager, start_pos: Vector2D<FixedNumberType>) -> Self { pub fn new_slime(object: &'a OamManaged, start_pos: Vector2D<FixedNumberType>) -> Self {
Enemy::Slime(Slime::new(object, start_pos + (0, 1).into())) Enemy::Slime(Slime::new(object, start_pos + (0, 1).into()))
} }
pub fn new_snail(object: &'a OamManager, start_pos: Vector2D<FixedNumberType>) -> Self { pub fn new_snail(object: &'a OamManaged, start_pos: Vector2D<FixedNumberType>) -> Self {
Enemy::Snail(Snail::new(object, start_pos)) Enemy::Snail(Snail::new(object, start_pos))
} }
@ -52,7 +52,7 @@ impl<'a> Enemy<'a> {
pub fn update( pub fn update(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
level: &Level, level: &Level,
player_pos: Vector2D<FixedNumberType>, player_pos: Vector2D<FixedNumberType>,
hat_state: HatState, hat_state: HatState,
@ -94,7 +94,7 @@ struct EnemyInfo<'a> {
impl<'a> EnemyInfo<'a> { impl<'a> EnemyInfo<'a> {
fn new( fn new(
object: &'a OamManager, object: &'a OamManaged,
start_pos: Vector2D<FixedNumberType>, start_pos: Vector2D<FixedNumberType>,
collision: Vector2D<u16>, collision: Vector2D<u16>,
) -> Self { ) -> Self {
@ -135,7 +135,7 @@ pub struct Slime<'a> {
} }
impl<'a> Slime<'a> { impl<'a> Slime<'a> {
fn new(object: &'a OamManager, start_pos: Vector2D<FixedNumberType>) -> Self { fn new(object: &'a OamManaged, start_pos: Vector2D<FixedNumberType>) -> Self {
let slime = Slime { let slime = Slime {
enemy_info: EnemyInfo::new(object, start_pos, (14u16, 14u16).into()), enemy_info: EnemyInfo::new(object, start_pos, (14u16, 14u16).into()),
state: SlimeState::Idle, state: SlimeState::Idle,
@ -146,7 +146,7 @@ impl<'a> Slime<'a> {
fn update( fn update(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
level: &Level, level: &Level,
player_pos: Vector2D<FixedNumberType>, player_pos: Vector2D<FixedNumberType>,
hat_state: HatState, hat_state: HatState,
@ -161,7 +161,7 @@ impl<'a> Slime<'a> {
let offset = (timer / 16) as usize; let offset = (timer / 16) as usize;
let frame = SLIME_IDLE.animation_sprite(offset); let frame = SLIME_IDLE.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
@ -201,7 +201,7 @@ impl<'a> Slime<'a> {
self.state = SlimeState::Idle; self.state = SlimeState::Idle;
} else { } else {
let frame = SLIME_JUMP.animation_sprite(offset); let frame = SLIME_JUMP.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
} }
@ -227,7 +227,7 @@ impl<'a> Slime<'a> {
} }
let frame = SLIME_SPLAT.animation_sprite(offset); let frame = SLIME_SPLAT.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
} }
@ -257,7 +257,7 @@ pub struct Snail<'a> {
} }
impl<'a> Snail<'a> { impl<'a> Snail<'a> {
fn new(object: &'a OamManager, start_pos: Vector2D<FixedNumberType>) -> Self { fn new(object: &'a OamManaged, start_pos: Vector2D<FixedNumberType>) -> Self {
let snail = Snail { let snail = Snail {
enemy_info: EnemyInfo::new(object, start_pos, (16u16, 16u16).into()), enemy_info: EnemyInfo::new(object, start_pos, (16u16, 16u16).into()),
state: SnailState::Idle(0), state: SnailState::Idle(0),
@ -272,7 +272,7 @@ impl<'a> Snail<'a> {
fn update( fn update(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
level: &Level, level: &Level,
player_pos: Vector2D<FixedNumberType>, player_pos: Vector2D<FixedNumberType>,
hat_state: HatState, hat_state: HatState,
@ -298,7 +298,7 @@ impl<'a> Snail<'a> {
} }
let frame = SNAIL_IDLE.animation_sprite(0); let frame = SNAIL_IDLE.animation_sprite(0);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
if player_has_collided { if player_has_collided {
@ -318,7 +318,7 @@ impl<'a> Snail<'a> {
self.enemy_info.entity.velocity = (0, 0).into(); self.enemy_info.entity.velocity = (0, 0).into();
let frame = SNAIL_EMERGE.animation_sprite(offset); let frame = SNAIL_EMERGE.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
@ -340,7 +340,7 @@ impl<'a> Snail<'a> {
let offset = (timer - time) as usize / 8; let offset = (timer - time) as usize / 8;
let frame = SNAIL_MOVE.animation_sprite(offset); let frame = SNAIL_MOVE.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
@ -374,7 +374,7 @@ impl<'a> Snail<'a> {
} }
let frame = SNAIL_EMERGE.animation_sprite(offset); let frame = SNAIL_EMERGE.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
self.enemy_info.entity.velocity = (0, 0).into(); self.enemy_info.entity.velocity = (0, 0).into();
@ -403,7 +403,7 @@ impl<'a> Snail<'a> {
return UpdateState::Remove; return UpdateState::Remove;
}; };
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite); self.enemy_info.entity.sprite.set_sprite(sprite);
self.enemy_info.entity.velocity = (0, 0).into(); self.enemy_info.entity.velocity = (0, 0).into();

View file

@ -8,7 +8,7 @@ extern crate alloc;
use agb::{ use agb::{
display::{ display::{
object::{Graphics, OamManager, Object, Tag, TagMap}, object::{Graphics, OamManaged, Object, Tag, TagMap},
tiled::{ tiled::{
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TileSet, InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TileSet,
TileSetting, TiledMap, VRamManager, TileSetting, TiledMap, VRamManager,
@ -124,8 +124,8 @@ pub struct Entity<'a> {
} }
impl<'a> Entity<'a> { impl<'a> Entity<'a> {
pub fn new(object: &'a OamManager, collision_mask: Vector2D<u16>) -> Self { pub fn new(object: &'a OamManaged, collision_mask: Vector2D<u16>) -> Self {
let mut dummy_object = object.add_object_static_sprite(WALKING.sprite(0)); let mut dummy_object = object.object_sprite(WALKING.sprite(0));
dummy_object.set_priority(Priority::P1); dummy_object.set_priority(Priority::P1);
Entity { Entity {
sprite: dummy_object, sprite: dummy_object,
@ -347,15 +347,15 @@ fn ping_pong(i: i32, n: i32) -> i32 {
} }
impl<'a> Player<'a> { impl<'a> Player<'a> {
fn new(controller: &'a OamManager, start_position: Vector2D<FixedNumberType>) -> Self { fn new(controller: &'a OamManaged, start_position: Vector2D<FixedNumberType>) -> Self {
let mut wizard = Entity::new(controller, (6_u16, 14_u16).into()); let mut wizard = Entity::new(controller, (6_u16, 14_u16).into());
let mut hat = Entity::new(controller, (6_u16, 6_u16).into()); let mut hat = Entity::new(controller, (6_u16, 6_u16).into());
wizard wizard
.sprite .sprite
.set_sprite(controller.get_vram_sprite(HAT_SPIN_1.sprite(0))); .set_sprite(controller.get_sprite(HAT_SPIN_1.sprite(0)));
hat.sprite hat.sprite
.set_sprite(controller.get_vram_sprite(HAT_SPIN_1.sprite(0))); .set_sprite(controller.get_sprite(HAT_SPIN_1.sprite(0)));
wizard.sprite.show(); wizard.sprite.show();
hat.sprite.show(); hat.sprite.show();
@ -381,7 +381,7 @@ impl<'a> Player<'a> {
fn update_frame( fn update_frame(
&mut self, &mut self,
input: &ButtonController, input: &ButtonController,
controller: &'a OamManager, controller: &'a OamManaged,
timer: i32, timer: i32,
level: &Level, level: &Level,
enemies: &[enemies::Enemy], enemies: &[enemies::Enemy],
@ -460,7 +460,7 @@ impl<'a> Player<'a> {
self.wizard_frame = offset as u8; self.wizard_frame = offset as u8;
let frame = WALKING.animation_sprite(offset); let frame = WALKING.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.wizard.sprite.set_sprite(sprite); self.wizard.sprite.set_sprite(sprite);
} }
@ -470,7 +470,7 @@ impl<'a> Player<'a> {
self.wizard_frame = 5; self.wizard_frame = 5;
let frame = JUMPING.animation_sprite(0); let frame = JUMPING.animation_sprite(0);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.wizard.sprite.set_sprite(sprite); self.wizard.sprite.set_sprite(sprite);
} else if self.wizard.velocity.y > FixedNumberType::new(1) / 16 { } else if self.wizard.velocity.y > FixedNumberType::new(1) / 16 {
@ -485,7 +485,7 @@ impl<'a> Player<'a> {
self.wizard_frame = 0; self.wizard_frame = 0;
let frame = FALLING.animation_sprite(offset); let frame = FALLING.animation_sprite(offset);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.wizard.sprite.set_sprite(sprite); self.wizard.sprite.set_sprite(sprite);
} }
@ -512,13 +512,13 @@ impl<'a> Player<'a> {
self.wizard.sprite.set_hflip(true); self.wizard.sprite.set_hflip(true);
self.hat self.hat
.sprite .sprite
.set_sprite(controller.get_vram_sprite(hat_base_tile.sprite(5))); .set_sprite(controller.get_sprite(hat_base_tile.sprite(5)));
} }
agb::input::Tri::Positive => { agb::input::Tri::Positive => {
self.wizard.sprite.set_hflip(false); self.wizard.sprite.set_hflip(false);
self.hat self.hat
.sprite .sprite
.set_sprite(controller.get_vram_sprite(hat_base_tile.sprite(0))); .set_sprite(controller.get_sprite(hat_base_tile.sprite(0)));
} }
_ => {} _ => {}
} }
@ -544,7 +544,7 @@ impl<'a> Player<'a> {
let hat_sprite_offset = (timer / hat_sprite_divider) as usize; let hat_sprite_offset = (timer / hat_sprite_divider) as usize;
self.hat.sprite.set_sprite( self.hat.sprite.set_sprite(
controller.get_vram_sprite(hat_base_tile.animation_sprite(hat_sprite_offset)), controller.get_sprite(hat_base_tile.animation_sprite(hat_sprite_offset)),
); );
if self.hat_slow_counter < 30 && self.hat.velocity.magnitude() < 2.into() { if self.hat_slow_counter < 30 && self.hat.velocity.magnitude() < 2.into() {
@ -577,7 +577,7 @@ impl<'a> Player<'a> {
} }
HatState::WizardTowards => { HatState::WizardTowards => {
self.hat.sprite.set_sprite( self.hat.sprite.set_sprite(
controller.get_vram_sprite(hat_base_tile.animation_sprite(timer as usize / 2)), controller.get_sprite(hat_base_tile.animation_sprite(timer as usize / 2)),
); );
let distance_vector = let distance_vector =
self.hat.position - self.wizard.position + hat_resting_position; self.hat.position - self.wizard.position + hat_resting_position;
@ -615,7 +615,7 @@ enum UpdateState {
impl<'a, 'b> PlayingLevel<'a, 'b> { impl<'a, 'b> PlayingLevel<'a, 'b> {
fn open_level( fn open_level(
level: &'a Level, level: &'a Level,
object_control: &'a OamManager, object_control: &'a OamManaged,
background: &'a mut InfiniteScrolledMap<'b>, background: &'a mut InfiniteScrolledMap<'b>,
foreground: &'a mut InfiniteScrolledMap<'b>, foreground: &'a mut InfiniteScrolledMap<'b>,
input: ButtonController, input: ButtonController,
@ -676,11 +676,11 @@ impl<'a, 'b> PlayingLevel<'a, 'b> {
self.player.wizard.sprite.set_priority(Priority::P0); self.player.wizard.sprite.set_priority(Priority::P0);
} }
fn dead_update(&mut self, controller: &'a OamManager) -> bool { fn dead_update(&mut self, controller: &'a OamManaged) -> bool {
self.timer += 1; self.timer += 1;
let frame = PLAYER_DEATH.animation_sprite(self.timer as usize / 8); let frame = PLAYER_DEATH.animation_sprite(self.timer as usize / 8);
let sprite = controller.get_vram_sprite(frame); let sprite = controller.get_sprite(frame);
self.player.wizard.velocity += (0.into(), FixedNumberType::new(1) / 32).into(); self.player.wizard.velocity += (0.into(), FixedNumberType::new(1) / 32).into();
self.player.wizard.position += self.player.wizard.velocity; self.player.wizard.position += self.player.wizard.velocity;
@ -695,7 +695,7 @@ impl<'a, 'b> PlayingLevel<'a, 'b> {
&mut self, &mut self,
sfx_player: &mut SfxPlayer, sfx_player: &mut SfxPlayer,
vram: &mut VRamManager, vram: &mut VRamManager,
controller: &'a OamManager, controller: &'a OamManaged,
) -> UpdateState { ) -> UpdateState {
self.timer += 1; self.timer += 1;
self.input.update(); self.input.update();

View file

@ -14,7 +14,7 @@ use alloc::{boxed::Box, vec::Vec};
use agb::{ use agb::{
display::{ display::{
object::{Graphics, OamManager, Object, Sprite, Tag, TagMap}, object::{Graphics, OamManaged, Object, Sprite, Tag, TagMap},
tiled::{ tiled::{
InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, TileSetting, InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, TileSetting,
VRamManager, VRamManager,
@ -164,8 +164,8 @@ struct Entity<'a> {
} }
impl<'a> Entity<'a> { impl<'a> Entity<'a> {
fn new(object_controller: &'a OamManager, collision_mask: Rect<u16>) -> Self { fn new(object_controller: &'a OamManaged, collision_mask: Rect<u16>) -> Self {
let mut sprite = object_controller.add_object_static_sprite(LONG_SWORD_IDLE.sprite(0)); let mut sprite = object_controller.object_sprite(LONG_SWORD_IDLE.sprite(0));
sprite.set_priority(Priority::P1); sprite.set_priority(Priority::P1);
Entity { Entity {
sprite, sprite,
@ -532,12 +532,12 @@ struct Player<'a> {
} }
impl<'a> Player<'a> { impl<'a> Player<'a> {
fn new(object_controller: &'a OamManager<'a>) -> Player { fn new(object_controller: &'a OamManaged<'_>) -> Player<'a> {
let mut entity = Entity::new( let mut entity = Entity::new(
object_controller, object_controller,
Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()), Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()),
); );
let s = object_controller.get_vram_sprite(LONG_SWORD_IDLE.sprite(0)); let s = object_controller.get_sprite(LONG_SWORD_IDLE.sprite(0));
entity.sprite.set_sprite(s); entity.sprite.set_sprite(s);
entity.sprite.show(); entity.sprite.show();
entity.position = (144, 0).into(); entity.position = (144, 0).into();
@ -558,7 +558,7 @@ impl<'a> Player<'a> {
fn update( fn update(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
buttons: &ButtonController, buttons: &ButtonController,
level: &Level, level: &Level,
sfx: &mut sfx::Sfx, sfx: &mut sfx::Sfx,
@ -590,11 +590,11 @@ impl<'a> Player<'a> {
self.entity.velocity.x += self.sword.ground_walk_force() * x as i32; self.entity.velocity.x += self.sword.ground_walk_force() * x as i32;
if self.entity.velocity.x.abs() > Number::new(1) / 10 { if self.entity.velocity.x.abs() > Number::new(1) / 10 {
let sprite = controller let sprite = controller
.get_vram_sprite(self.sword.walk_animation(self.sprite_offset)); .get_sprite(self.sword.walk_animation(self.sprite_offset));
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
} else { } else {
let sprite = controller let sprite = controller
.get_vram_sprite(self.sword.idle_animation(self.sprite_offset)); .get_sprite(self.sword.idle_animation(self.sprite_offset));
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
} }
@ -614,8 +614,7 @@ impl<'a> Player<'a> {
let frame = self.sword.attack_frame(*a); let frame = self.sword.attack_frame(*a);
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32; self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
let tag = self.sword.attack_tag(); let tag = self.sword.attack_tag();
let sprite = let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
hurtbox = self.sword.ground_attack_hurtbox(frame); hurtbox = self.sword.ground_attack_hurtbox(frame);
@ -629,8 +628,7 @@ impl<'a> Player<'a> {
let frame = self.sword.hold_frame(); let frame = self.sword.hold_frame();
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32; self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
let tag = self.sword.attack_tag(); let tag = self.sword.attack_tag();
let sprite = let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
if *a == 0 { if *a == 0 {
self.attack_timer = AttackTimer::Idle; self.attack_timer = AttackTimer::Idle;
@ -655,8 +653,7 @@ impl<'a> Player<'a> {
2 2
}; };
let tag = self.sword.jump_tag(); let tag = self.sword.jump_tag();
let sprite = let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
if x != Tri::Zero { if x != Tri::Zero {
@ -678,8 +675,7 @@ impl<'a> Player<'a> {
*a -= 1; *a -= 1;
let frame = self.sword.jump_attack_frame(*a); let frame = self.sword.jump_attack_frame(*a);
let tag = self.sword.jump_attack_tag(); let tag = self.sword.jump_attack_tag();
let sprite = let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
hurtbox = self.sword.air_attack_hurtbox(frame); hurtbox = self.sword.air_attack_hurtbox(frame);
@ -814,7 +810,7 @@ impl BatData {
fn update<'a>( fn update<'a>(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
entity: &mut Entity<'a>, entity: &mut Entity<'a>,
player: &Player, player: &Player,
level: &Level, level: &Level,
@ -842,7 +838,7 @@ impl BatData {
} }
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 8); let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 8);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -877,7 +873,7 @@ impl BatData {
} }
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 2); let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 2);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -904,7 +900,7 @@ impl BatData {
BatState::Dead => { BatState::Dead => {
const BAT_DEAD: &Tag = TAG_MAP.get("bat dead"); const BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
let sprite = BAT_DEAD.sprite(0); let sprite = BAT_DEAD.sprite(0);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -947,7 +943,7 @@ impl SlimeData {
fn update<'a>( fn update<'a>(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
entity: &mut Entity<'a>, entity: &mut Entity<'a>,
player: &Player, player: &Player,
level: &Level, level: &Level,
@ -972,7 +968,7 @@ impl SlimeData {
const IDLE: &Tag = TAG_MAP.get("slime idle"); const IDLE: &Tag = TAG_MAP.get("slime idle");
let sprite = IDLE.sprite(self.sprite_offset as usize / 16); let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -1012,7 +1008,7 @@ impl SlimeData {
const CHASE: &Tag = TAG_MAP.get("Slime jump"); const CHASE: &Tag = TAG_MAP.get("Slime jump");
let sprite = CHASE.sprite(frame as usize); let sprite = CHASE.sprite(frame as usize);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -1042,7 +1038,7 @@ impl SlimeData {
if *count < 5 * 4 { if *count < 5 * 4 {
const DEATH: &Tag = TAG_MAP.get("Slime death"); const DEATH: &Tag = TAG_MAP.get("Slime death");
let sprite = DEATH.sprite(*count as usize / 4); let sprite = DEATH.sprite(*count as usize / 4);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
*count += 1; *count += 1;
@ -1076,7 +1072,7 @@ impl MiniFlameData {
fn update<'a>( fn update<'a>(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
entity: &mut Entity<'a>, entity: &mut Entity<'a>,
player: &Player, player: &Player,
_level: &Level, _level: &Level,
@ -1110,7 +1106,7 @@ impl MiniFlameData {
} }
} else { } else {
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 8); let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 8);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
entity.velocity = (0.into(), Number::new(-1) / Number::new(4)).into(); entity.velocity = (0.into(), Number::new(-1) / Number::new(4)).into();
@ -1158,7 +1154,7 @@ impl MiniFlameData {
} }
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 2); let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 2);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
} }
MiniFlameState::Dead => { MiniFlameState::Dead => {
@ -1170,7 +1166,7 @@ impl MiniFlameData {
const DEATH: &Tag = TAG_MAP.get("angry boss dead"); const DEATH: &Tag = TAG_MAP.get("angry boss dead");
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12); let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
self.sprite_offset += 1; self.sprite_offset += 1;
@ -1205,7 +1201,7 @@ impl EmuData {
fn update<'a>( fn update<'a>(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
entity: &mut Entity<'a>, entity: &mut Entity<'a>,
player: &Player, player: &Player,
level: &Level, level: &Level,
@ -1231,7 +1227,7 @@ impl EmuData {
const IDLE: &Tag = TAG_MAP.get("emu - idle"); const IDLE: &Tag = TAG_MAP.get("emu - idle");
let sprite = IDLE.sprite(self.sprite_offset as usize / 16); let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
if (entity.position.y - player.entity.position.y).abs() < 10.into() { if (entity.position.y - player.entity.position.y).abs() < 10.into() {
@ -1278,7 +1274,7 @@ impl EmuData {
const WALK: &Tag = TAG_MAP.get("emu-walk"); const WALK: &Tag = TAG_MAP.get("emu-walk");
let sprite = WALK.sprite(self.sprite_offset as usize / 2); let sprite = WALK.sprite(self.sprite_offset as usize / 2);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
let gravity: Number = 1.into(); let gravity: Number = 1.into();
@ -1333,7 +1329,7 @@ impl EmuData {
const DEATH: &Tag = TAG_MAP.get("emu - die"); const DEATH: &Tag = TAG_MAP.get("emu - die");
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4); let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
self.sprite_offset += 1; self.sprite_offset += 1;
@ -1378,7 +1374,7 @@ impl EnemyData {
fn update<'a>( fn update<'a>(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
entity: &mut Entity<'a>, entity: &mut Entity<'a>,
player: &Player, player: &Player,
level: &Level, level: &Level,
@ -1399,11 +1395,11 @@ struct Enemy<'a> {
} }
impl<'a> Enemy<'a> { impl<'a> Enemy<'a> {
fn new(object_controller: &'a OamManager, enemy_data: EnemyData) -> Self { fn new(object_controller: &'a OamManaged, enemy_data: EnemyData) -> Self {
let mut entity = Entity::new(object_controller, enemy_data.collision_mask()); let mut entity = Entity::new(object_controller, enemy_data.collision_mask());
let sprite = enemy_data.sprite(); let sprite = enemy_data.sprite();
let sprite = object_controller.get_vram_sprite(sprite); let sprite = object_controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
entity.sprite.show(); entity.sprite.show();
@ -1413,7 +1409,7 @@ impl<'a> Enemy<'a> {
fn update( fn update(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
player: &Player, player: &Player,
level: &Level, level: &Level,
sfx: &mut sfx::Sfx, sfx: &mut sfx::Sfx,
@ -1444,7 +1440,7 @@ impl ParticleData {
fn update<'a>( fn update<'a>(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
entity: &mut Entity<'a>, entity: &mut Entity<'a>,
player: &Player, player: &Player,
_level: &Level, _level: &Level,
@ -1457,7 +1453,7 @@ impl ParticleData {
const DUST: &Tag = TAG_MAP.get("dust"); const DUST: &Tag = TAG_MAP.get("dust");
let sprite = DUST.sprite(*frame as usize / 3); let sprite = DUST.sprite(*frame as usize / 3);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -1471,7 +1467,7 @@ impl ParticleData {
const HEALTH: &Tag = TAG_MAP.get("Heath"); const HEALTH: &Tag = TAG_MAP.get("Heath");
let sprite = HEALTH.animation_sprite(*frame as usize / 3); let sprite = HEALTH.animation_sprite(*frame as usize / 3);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -1497,7 +1493,7 @@ impl ParticleData {
ParticleData::BossHealer(frame, target) => { ParticleData::BossHealer(frame, target) => {
const HEALTH: &Tag = TAG_MAP.get("Heath"); const HEALTH: &Tag = TAG_MAP.get("Heath");
let sprite = HEALTH.animation_sprite(*frame as usize / 3); let sprite = HEALTH.animation_sprite(*frame as usize / 3);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
entity.sprite.set_sprite(sprite); entity.sprite.set_sprite(sprite);
@ -1532,7 +1528,7 @@ struct Particle<'a> {
impl<'a> Particle<'a> { impl<'a> Particle<'a> {
fn new( fn new(
object_controller: &'a OamManager, object_controller: &'a OamManaged,
particle_data: ParticleData, particle_data: ParticleData,
position: Vector2D<Number>, position: Vector2D<Number>,
) -> Self { ) -> Self {
@ -1551,7 +1547,7 @@ impl<'a> Particle<'a> {
fn update( fn update(
&mut self, &mut self,
controller: &'a OamManager, controller: &'a OamManaged,
player: &Player, player: &Player,
level: &Level, level: &Level,
) -> UpdateInstruction { ) -> UpdateInstruction {
@ -1578,7 +1574,7 @@ impl<'a> BossState<'a> {
fn update( fn update(
&mut self, &mut self,
enemies: &mut Arena<Enemy<'a>>, enemies: &mut Arena<Enemy<'a>>,
object_controller: &'a OamManager, object_controller: &'a OamManaged,
player: &Player, player: &Player,
sfx: &mut sfx::Sfx, sfx: &mut sfx::Sfx,
) -> BossInstruction { ) -> BossInstruction {
@ -1613,7 +1609,7 @@ struct FollowingBoss<'a> {
} }
impl<'a> FollowingBoss<'a> { impl<'a> FollowingBoss<'a> {
fn new(object_controller: &'a OamManager, position: Vector2D<Number>) -> Self { fn new(object_controller: &'a OamManaged, position: Vector2D<Number>) -> Self {
let mut entity = Entity::new( let mut entity = Entity::new(
object_controller, object_controller,
Rect::new((0_u16, 0_u16).into(), (0_u16, 0_u16).into()), Rect::new((0_u16, 0_u16).into(), (0_u16, 0_u16).into()),
@ -1628,7 +1624,7 @@ impl<'a> FollowingBoss<'a> {
gone: false, gone: false,
} }
} }
fn update(&mut self, controller: &'a OamManager, player: &Player) { fn update(&mut self, controller: &'a OamManaged, player: &Player) {
let difference = player.entity.position - self.entity.position; let difference = player.entity.position - self.entity.position;
self.timer += 1; self.timer += 1;
@ -1661,7 +1657,7 @@ impl<'a> FollowingBoss<'a> {
const BOSS: &Tag = TAG_MAP.get("happy boss"); const BOSS: &Tag = TAG_MAP.get("happy boss");
let sprite = BOSS.animation_sprite(frame as usize); let sprite = BOSS.animation_sprite(frame as usize);
let sprite = controller.get_vram_sprite(sprite); let sprite = controller.get_sprite(sprite);
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
@ -1697,7 +1693,7 @@ enum BossInstruction {
} }
impl<'a> Boss<'a> { impl<'a> Boss<'a> {
fn new(object_controller: &'a OamManager, screen_coords: Vector2D<Number>) -> Self { fn new(object_controller: &'a OamManaged, screen_coords: Vector2D<Number>) -> Self {
let mut entity = Entity::new( let mut entity = Entity::new(
object_controller, object_controller,
Rect::new((0_u16, 0_u16).into(), (28_u16, 28_u16).into()), Rect::new((0_u16, 0_u16).into(), (28_u16, 28_u16).into()),
@ -1716,7 +1712,7 @@ impl<'a> Boss<'a> {
fn update( fn update(
&mut self, &mut self,
enemies: &mut Arena<Enemy<'a>>, enemies: &mut Arena<Enemy<'a>>,
object_controller: &'a OamManager, object_controller: &'a OamManaged,
player: &Player, player: &Player,
sfx: &mut sfx::Sfx, sfx: &mut sfx::Sfx,
) -> BossInstruction { ) -> BossInstruction {
@ -1797,7 +1793,7 @@ impl<'a> Boss<'a> {
const BOSS: &Tag = TAG_MAP.get("Boss"); const BOSS: &Tag = TAG_MAP.get("Boss");
let sprite = BOSS.animation_sprite(frame as usize); let sprite = BOSS.animation_sprite(frame as usize);
let sprite = object_controller.get_vram_sprite(sprite); let sprite = object_controller.get_sprite(sprite);
self.entity.sprite.set_sprite(sprite); self.entity.sprite.set_sprite(sprite);
@ -1820,7 +1816,7 @@ impl<'a> Boss<'a> {
self.entity self.entity
.commit_with_size(offset + shake, (32, 32).into()); .commit_with_size(offset + shake, (32, 32).into());
} }
fn explode(&self, enemies: &mut Arena<Enemy<'a>>, object_controller: &'a OamManager) { fn explode(&self, enemies: &mut Arena<Enemy<'a>>, object_controller: &'a OamManaged) {
for _ in 0..(6 - self.health) { for _ in 0..(6 - self.health) {
let x_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1; let x_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1;
let y_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1; let y_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1;
@ -1894,7 +1890,7 @@ impl<'a> Game<'a> {
fn advance_frame( fn advance_frame(
&mut self, &mut self,
object_controller: &'a OamManager, object_controller: &'a OamManaged,
vram: &mut VRamManager, vram: &mut VRamManager,
sfx: &mut sfx::Sfx, sfx: &mut sfx::Sfx,
) -> GameStatus { ) -> GameStatus {
@ -2108,7 +2104,7 @@ impl<'a> Game<'a> {
} }
} }
fn load_enemies(&mut self, object_controller: &'a OamManager) { fn load_enemies(&mut self, object_controller: &'a OamManaged) {
if self.slime_load < self.level.slime_spawns.len() { if self.slime_load < self.level.slime_spawns.len() {
for (idx, slime_spawn) in self for (idx, slime_spawn) in self
.level .level
@ -2178,7 +2174,7 @@ impl<'a> Game<'a> {
vram.set_background_palettes(&modified_palettes); vram.set_background_palettes(&modified_palettes);
} }
fn new(object: &'a OamManager<'a>, level: Level<'a>, start_at_boss: bool) -> Self { fn new(object: &'a OamManaged<'a>, level: Level<'a>, start_at_boss: bool) -> Self {
let mut player = Player::new(object); let mut player = Player::new(object);
let mut offset = (8, 8).into(); let mut offset = (8, 8).into();
if start_at_boss { if start_at_boss {