reverse change of name

This commit is contained in:
Corwin 2023-04-23 18:55:23 +01:00
parent e26a9c2c24
commit 14c7028aa0
No known key found for this signature in database
10 changed files with 70 additions and 79 deletions

View file

@ -76,7 +76,7 @@ fn main(mut gba: agb::Gba) -> ! {
let object = gba.display.object.get_managed();
let sprite = object.get_sprite(&CHICKEN_SPRITES[0]);
let sprite = object.sprite(&CHICKEN_SPRITES[0]);
let mut chicken = Character {
object: object.object(sprite),
position: Vector2D {
@ -157,20 +157,18 @@ fn update_chicken_object(
match state {
State::Ground => {
if chicken.velocity.x.abs() > 1 << 4 {
chicken.object.set_sprite(
gfx.get_sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 1, 3, 10)]),
);
} else {
chicken
.object
.set_sprite(gfx.get_sprite(&CHICKEN_SPRITES[0]));
.set_sprite(gfx.sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 1, 3, 10)]));
} else {
chicken.object.set_sprite(gfx.sprite(&CHICKEN_SPRITES[0]));
}
}
State::Upwards => {}
State::Flapping => {
chicken
.object
.set_sprite(gfx.get_sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 4, 5, 5)]));
.set_sprite(gfx.sprite(&CHICKEN_SPRITES[frame_ranger(frame_count, 4, 5, 5)]));
}
}

View file

@ -68,7 +68,7 @@ fn all_sprites(gfx: &OamManaged, rotation_speed: Num<i32, 16>) {
image %= SPRITES.len();
for (i, obj) in objs.iter_mut().enumerate() {
let this_image = (image + i) % SPRITES.len();
obj.set_sprite(gfx.get_sprite(&SPRITES[this_image]));
obj.set_sprite(gfx.sprite(&SPRITES[this_image]));
}
}
gfx.commit();
@ -110,7 +110,7 @@ fn all_tags(gfx: &OamManaged) {
if count % 5 == 0 {
image += 1;
for (obj, tag) in objs.iter_mut() {
obj.set_sprite(gfx.get_sprite(tag.animation_sprite(image)));
obj.set_sprite(gfx.sprite(tag.animation_sprite(image)));
}
gfx.commit();
}

View file

@ -190,7 +190,7 @@ impl OamManaged<'_> {
}
/// Creates a sprite in vram from a static sprite from [`include_aseprite`][crate::include_aseprite].
pub fn get_sprite(&self, sprite: &'static Sprite) -> SpriteVram {
pub fn sprite(&self, sprite: &'static Sprite) -> SpriteVram {
// safety: not reentrant
unsafe {
self.do_work_with_sprite_loader(|sprite_loader| sprite_loader.get_vram_sprite(sprite))
@ -199,7 +199,7 @@ impl OamManaged<'_> {
/// Creates a sprite in vram and uses it to make an object from a static sprite from [`include_aseprite`][crate::include_aseprite].
pub fn object_sprite(&self, sprite: &'static Sprite) -> Object<'_> {
self.object(self.get_sprite(sprite))
self.object(self.sprite(sprite))
}
}
@ -486,7 +486,7 @@ mod tests {
fn test_always_ordered(gba: &mut crate::Gba) {
let managed = gba.display.object.get_managed();
let sprite = managed.get_sprite(TEST_SPRITE);
let sprite = managed.sprite(TEST_SPRITE);
let mut objects = Vec::new();
for _ in 0..200 {

View file

@ -585,10 +585,7 @@ pub(crate) fn battle_screen(
select_box_obj
.set_y(120 - 4)
.set_x(selected_die as u16 * 40 + 28 - 4)
.set_sprite(
agb.obj
.get_sprite(SELECT_BOX.animation_sprite(counter / 10)),
);
.set_sprite(agb.obj.sprite(SELECT_BOX.animation_sprite(counter / 10)));
agb.star_background.update();
agb.sfx.frame();

View file

@ -195,7 +195,7 @@ impl<'a> BattleScreenDisplay<'a> {
if i < current_battle_state.player.shield_count as usize {
player_shield
.show()
.set_sprite(obj.get_sprite(SHIELD.sprite(0)));
.set_sprite(obj.sprite(SHIELD.sprite(0)));
} else {
player_shield.hide();
}
@ -205,7 +205,7 @@ impl<'a> BattleScreenDisplay<'a> {
if i < current_battle_state.enemy.shield_count as usize {
player_shield
.show()
.set_sprite(obj.get_sprite(SHIELD.sprite(0)));
.set_sprite(obj.sprite(SHIELD.sprite(0)));
} else {
player_shield.hide();
}
@ -249,7 +249,7 @@ impl<'a> BattleScreenDisplay<'a> {
.zip(current_battle_state.rolled_dice.faces_to_render())
.zip(self.objs.dice_cooldowns.iter_mut())
{
die_obj.set_sprite(obj.get_sprite(FACE_SPRITES.sprite_for_face(current_face)));
die_obj.set_sprite(obj.sprite(FACE_SPRITES.sprite_for_face(current_face)));
if let Some(cooldown) = cooldown {
cooldown_healthbar
@ -311,7 +311,7 @@ impl<'a> EnemyAttackDisplay<'a> {
pub fn update(&mut self, attack: &Option<EnemyAttackState>, obj: &'a OamManaged) {
if let Some(attack) = attack {
self.face.show().set_sprite(
obj.get_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(attack.attack_type())),
obj.sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(attack.attack_type())),
);
self.cooldown
.set_value((attack.cooldown * 48 / attack.max_cooldown) as usize, obj);
@ -413,7 +413,7 @@ impl<'a> AnimationStateHolder<'a> {
for i in current_player_shields..*amount {
objs.player_shield[i as usize]
.show()
.set_sprite(obj.get_sprite(SHIELD.sprite(3 - *frame / 2)));
.set_sprite(obj.sprite(SHIELD.sprite(3 - *frame / 2)));
}
} else {
return AnimationUpdateState::RemoveWithAction(self.action.clone());
@ -444,7 +444,7 @@ impl<'a> AnimationStateHolder<'a> {
for i in current_enemy_shields..*amount {
objs.enemy_shield[i as usize]
.show()
.set_sprite(obj.get_sprite(SHIELD.sprite(3 - *frame / 2)));
.set_sprite(obj.sprite(SHIELD.sprite(3 - *frame / 2)));
}
} else {
return AnimationUpdateState::RemoveWithAction(self.action.clone());
@ -467,7 +467,7 @@ impl<'a> AnimationStateHolder<'a> {
AnimationState::PlayerBurstShield { frame } => {
if *frame < 10 {
for shield in objs.player_shield.iter_mut() {
shield.set_sprite(obj.get_sprite(SHIELD.sprite(*frame / 2)));
shield.set_sprite(obj.sprite(SHIELD.sprite(*frame / 2)));
}
*frame += 1;
@ -475,7 +475,7 @@ impl<'a> AnimationStateHolder<'a> {
AnimationUpdateState::Continue
} else {
for shield in objs.player_shield.iter_mut() {
shield.set_sprite(obj.get_sprite(SHIELD.sprite(0)));
shield.set_sprite(obj.sprite(SHIELD.sprite(0)));
}
AnimationUpdateState::RemoveWithAction(self.action.clone())

View file

@ -338,10 +338,7 @@ pub(crate) fn customise_screen(
break;
}
select_box.set_sprite(
agb.obj
.get_sprite(SELECT_BOX.animation_sprite(counter / 10)),
);
select_box.set_sprite(agb.obj.sprite(SELECT_BOX.animation_sprite(counter / 10)));
agb.star_background.update();
let _ = agb::rng::gen();

View file

@ -162,11 +162,11 @@ impl<'a> HealthBar<'a> {
for (i, sprite) in self.sprites.iter_mut().enumerate() {
if (i + 1) * 8 < new_value {
sprite.set_sprite(obj.get_sprite(SMALL_SPRITES.red_bar(0)));
sprite.set_sprite(obj.sprite(SMALL_SPRITES.red_bar(0)));
} else if i * 8 < new_value {
sprite.set_sprite(obj.get_sprite(SMALL_SPRITES.red_bar(8 - (new_value - i * 8))));
sprite.set_sprite(obj.sprite(SMALL_SPRITES.red_bar(8 - (new_value - i * 8))));
} else {
sprite.set_sprite(obj.get_sprite(SMALL_SPRITES.red_bar(8)));
sprite.set_sprite(obj.sprite(SMALL_SPRITES.red_bar(8)));
}
}
}
@ -233,13 +233,12 @@ impl<'a> FractionDisplay<'a> {
current /= 10;
let current_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 2];
current_value_sprite
.set_sprite(obj.get_sprite(SMALL_SPRITES.number(current_value_digit as u32)));
.set_sprite(obj.sprite(SMALL_SPRITES.number(current_value_digit as u32)));
let max_value_digit = max % 10;
max /= 10;
let max_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 1];
max_value_sprite
.set_sprite(obj.get_sprite(SMALL_SPRITES.number(max_value_digit as u32)));
max_value_sprite.set_sprite(obj.sprite(SMALL_SPRITES.number(max_value_digit as u32)));
}
}
}

View file

@ -161,7 +161,7 @@ impl<'a> Slime<'a> {
let offset = (timer / 16) as usize;
let frame = SLIME_IDLE.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
@ -201,7 +201,7 @@ impl<'a> Slime<'a> {
self.state = SlimeState::Idle;
} else {
let frame = SLIME_JUMP.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
}
@ -227,7 +227,7 @@ impl<'a> Slime<'a> {
}
let frame = SLIME_SPLAT.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
}
@ -298,7 +298,7 @@ impl<'a> Snail<'a> {
}
let frame = SNAIL_IDLE.animation_sprite(0);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
if player_has_collided {
@ -318,7 +318,7 @@ impl<'a> Snail<'a> {
self.enemy_info.entity.velocity = (0, 0).into();
let frame = SNAIL_EMERGE.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
@ -340,7 +340,7 @@ impl<'a> Snail<'a> {
let offset = (timer - time) as usize / 8;
let frame = SNAIL_MOVE.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
@ -374,7 +374,7 @@ impl<'a> Snail<'a> {
}
let frame = SNAIL_EMERGE.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
self.enemy_info.entity.velocity = (0, 0).into();
@ -403,7 +403,7 @@ impl<'a> Snail<'a> {
return UpdateState::Remove;
};
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.enemy_info.entity.sprite.set_sprite(sprite);
self.enemy_info.entity.velocity = (0, 0).into();

View file

@ -353,9 +353,9 @@ impl<'a> Player<'a> {
wizard
.sprite
.set_sprite(controller.get_sprite(HAT_SPIN_1.sprite(0)));
.set_sprite(controller.sprite(HAT_SPIN_1.sprite(0)));
hat.sprite
.set_sprite(controller.get_sprite(HAT_SPIN_1.sprite(0)));
.set_sprite(controller.sprite(HAT_SPIN_1.sprite(0)));
wizard.sprite.show();
hat.sprite.show();
@ -460,7 +460,7 @@ impl<'a> Player<'a> {
self.wizard_frame = offset as u8;
let frame = WALKING.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.wizard.sprite.set_sprite(sprite);
}
@ -470,7 +470,7 @@ impl<'a> Player<'a> {
self.wizard_frame = 5;
let frame = JUMPING.animation_sprite(0);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.wizard.sprite.set_sprite(sprite);
} else if self.wizard.velocity.y > FixedNumberType::new(1) / 16 {
@ -485,7 +485,7 @@ impl<'a> Player<'a> {
self.wizard_frame = 0;
let frame = FALLING.animation_sprite(offset);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.wizard.sprite.set_sprite(sprite);
}
@ -512,13 +512,13 @@ impl<'a> Player<'a> {
self.wizard.sprite.set_hflip(true);
self.hat
.sprite
.set_sprite(controller.get_sprite(hat_base_tile.sprite(5)));
.set_sprite(controller.sprite(hat_base_tile.sprite(5)));
}
agb::input::Tri::Positive => {
self.wizard.sprite.set_hflip(false);
self.hat
.sprite
.set_sprite(controller.get_sprite(hat_base_tile.sprite(0)));
.set_sprite(controller.sprite(hat_base_tile.sprite(0)));
}
_ => {}
}
@ -544,7 +544,7 @@ impl<'a> Player<'a> {
let hat_sprite_offset = (timer / hat_sprite_divider) as usize;
self.hat.sprite.set_sprite(
controller.get_sprite(hat_base_tile.animation_sprite(hat_sprite_offset)),
controller.sprite(hat_base_tile.animation_sprite(hat_sprite_offset)),
);
if self.hat_slow_counter < 30 && self.hat.velocity.magnitude() < 2.into() {
@ -577,7 +577,7 @@ impl<'a> Player<'a> {
}
HatState::WizardTowards => {
self.hat.sprite.set_sprite(
controller.get_sprite(hat_base_tile.animation_sprite(timer as usize / 2)),
controller.sprite(hat_base_tile.animation_sprite(timer as usize / 2)),
);
let distance_vector =
self.hat.position - self.wizard.position + hat_resting_position;
@ -680,7 +680,7 @@ impl<'a, 'b> PlayingLevel<'a, 'b> {
self.timer += 1;
let frame = PLAYER_DEATH.animation_sprite(self.timer as usize / 8);
let sprite = controller.get_sprite(frame);
let sprite = controller.sprite(frame);
self.player.wizard.velocity += (0.into(), FixedNumberType::new(1) / 32).into();
self.player.wizard.position += self.player.wizard.velocity;

View file

@ -524,7 +524,7 @@ struct Player<'a> {
impl<'a> Player<'a> {
fn new(object_controller: &'a OamManaged<'_>) -> Player<'a> {
let mut entity = Entity::new(object_controller, Rect::new((0, 1).into(), (5, 10).into()));
let s = object_controller.get_sprite(LONG_SWORD_IDLE.sprite(0));
let s = object_controller.sprite(LONG_SWORD_IDLE.sprite(0));
entity.sprite.set_sprite(s);
entity.sprite.show();
entity.position = (144, 0).into();
@ -576,12 +576,12 @@ impl<'a> Player<'a> {
self.entity.sprite.set_hflip(self.facing == Tri::Negative);
self.entity.velocity.x += self.sword.ground_walk_force() * x as i32;
if self.entity.velocity.x.abs() > Number::new(1) / 10 {
let sprite = controller
.get_sprite(self.sword.walk_animation(self.sprite_offset));
let sprite =
controller.sprite(self.sword.walk_animation(self.sprite_offset));
self.entity.sprite.set_sprite(sprite);
} else {
let sprite = controller
.get_sprite(self.sword.idle_animation(self.sprite_offset));
let sprite =
controller.sprite(self.sword.idle_animation(self.sprite_offset));
self.entity.sprite.set_sprite(sprite);
}
@ -601,7 +601,7 @@ impl<'a> Player<'a> {
let frame = self.sword.attack_frame(*a);
self.fudge_factor.x = (self.sword.fudge(frame) * self.facing as i32).into();
let tag = self.sword.attack_tag();
let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite);
hurtbox = self.sword.ground_attack_hurtbox(frame);
@ -615,7 +615,7 @@ impl<'a> Player<'a> {
let frame = self.sword.hold_frame();
self.fudge_factor.x = (self.sword.fudge(frame) * self.facing as i32).into();
let tag = self.sword.attack_tag();
let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite);
if *a == 0 {
self.attack_timer = AttackTimer::Idle;
@ -640,7 +640,7 @@ impl<'a> Player<'a> {
2
};
let tag = self.sword.jump_tag();
let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite);
if x != Tri::Zero {
@ -662,7 +662,7 @@ impl<'a> Player<'a> {
*a -= 1;
let frame = self.sword.jump_attack_frame(*a);
let tag = self.sword.jump_attack_tag();
let sprite = controller.get_sprite(tag.animation_sprite(frame as usize));
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
self.entity.sprite.set_sprite(sprite);
hurtbox = self.sword.air_attack_hurtbox(frame);
@ -827,7 +827,7 @@ impl BatData {
}
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 8);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -862,7 +862,7 @@ impl BatData {
}
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 2);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -889,7 +889,7 @@ impl BatData {
BatState::Dead => {
const BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
let sprite = BAT_DEAD.sprite(0);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -957,7 +957,7 @@ impl SlimeData {
const IDLE: &Tag = TAG_MAP.get("slime idle");
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -997,7 +997,7 @@ impl SlimeData {
const CHASE: &Tag = TAG_MAP.get("Slime jump");
let sprite = CHASE.sprite(frame as usize);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -1027,7 +1027,7 @@ impl SlimeData {
if *count < 5 * 4 {
const DEATH: &Tag = TAG_MAP.get("Slime death");
let sprite = DEATH.sprite(*count as usize / 4);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
*count += 1;
@ -1095,7 +1095,7 @@ impl MiniFlameData {
}
} else {
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 8);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
entity.velocity = (0.into(), Number::new(-1) / Number::new(4)).into();
@ -1143,7 +1143,7 @@ impl MiniFlameData {
}
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 2);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
}
MiniFlameState::Dead => {
@ -1155,7 +1155,7 @@ impl MiniFlameData {
const DEATH: &Tag = TAG_MAP.get("angry boss dead");
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
self.sprite_offset += 1;
@ -1216,7 +1216,7 @@ impl EmuData {
const IDLE: &Tag = TAG_MAP.get("emu - idle");
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
if (entity.position.y - player.entity.position.y).abs() < 10.into() {
@ -1263,7 +1263,7 @@ impl EmuData {
const WALK: &Tag = TAG_MAP.get("emu-walk");
let sprite = WALK.sprite(self.sprite_offset as usize / 2);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
let gravity: Number = 1.into();
@ -1318,7 +1318,7 @@ impl EmuData {
const DEATH: &Tag = TAG_MAP.get("emu - die");
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
self.sprite_offset += 1;
@ -1388,7 +1388,7 @@ impl<'a> Enemy<'a> {
let mut entity = Entity::new(object_controller, enemy_data.collision_mask());
let sprite = enemy_data.sprite();
let sprite = object_controller.get_sprite(sprite);
let sprite = object_controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
entity.sprite.show();
@ -1442,7 +1442,7 @@ impl ParticleData {
const DUST: &Tag = TAG_MAP.get("dust");
let sprite = DUST.sprite(*frame as usize / 3);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -1456,7 +1456,7 @@ impl ParticleData {
const HEALTH: &Tag = TAG_MAP.get("Heath");
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -1482,7 +1482,7 @@ impl ParticleData {
ParticleData::BossHealer(frame, target) => {
const HEALTH: &Tag = TAG_MAP.get("Heath");
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
entity.sprite.set_sprite(sprite);
@ -1640,7 +1640,7 @@ impl<'a> FollowingBoss<'a> {
const BOSS: &Tag = TAG_MAP.get("happy boss");
let sprite = BOSS.animation_sprite(frame as usize);
let sprite = controller.get_sprite(sprite);
let sprite = controller.sprite(sprite);
self.entity.sprite.set_sprite(sprite);
@ -1773,7 +1773,7 @@ impl<'a> Boss<'a> {
const BOSS: &Tag = TAG_MAP.get("Boss");
let sprite = BOSS.animation_sprite(frame as usize);
let sprite = object_controller.get_sprite(sprite);
let sprite = object_controller.sprite(sprite);
self.entity.sprite.set_sprite(sprite);