mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Rename get_sprite and get_animation_sprite to remove get_ prefix
This commit is contained in:
parent
35c7c48f73
commit
5791d033ef
|
@ -72,7 +72,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
let object = gba.display.object.get();
|
||||
|
||||
let sprite = object.get_sprite(&ChickenSprites[0]);
|
||||
let sprite = object.sprite(&ChickenSprites[0]);
|
||||
let mut chicken = Character {
|
||||
object: object.get_object(sprite),
|
||||
position: Vector2D {
|
||||
|
@ -154,19 +154,17 @@ fn update_chicken_object<'a>(
|
|||
State::Ground => {
|
||||
if chicken.velocity.x.abs() > 1 << 4 {
|
||||
chicken.object.set_sprite(
|
||||
object.get_sprite(&ChickenSprites[frame_ranger(frame_count, 1, 3, 10)]),
|
||||
object.sprite(&ChickenSprites[frame_ranger(frame_count, 1, 3, 10)]),
|
||||
);
|
||||
} else {
|
||||
chicken
|
||||
.object
|
||||
.set_sprite(object.get_sprite(&ChickenSprites[0]));
|
||||
chicken.object.set_sprite(object.sprite(&ChickenSprites[0]));
|
||||
}
|
||||
}
|
||||
State::Upwards => {}
|
||||
State::Flapping => {
|
||||
chicken
|
||||
.object
|
||||
.set_sprite(object.get_sprite(&ChickenSprites[frame_ranger(frame_count, 4, 5, 5)]));
|
||||
.set_sprite(object.sprite(&ChickenSprites[frame_ranger(frame_count, 4, 5, 5)]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ fn all_sprites(gfx: &ObjectController) {
|
|||
|
||||
for y in 0..9 {
|
||||
for x in 0..14 {
|
||||
let mut obj = gfx.get_object(gfx.get_sprite(&SPRITES[0]));
|
||||
let mut obj = gfx.get_object(gfx.sprite(&SPRITES[0]));
|
||||
obj.show();
|
||||
obj.set_position((x * 16 + 8, y * 16 + 8).into());
|
||||
objs.push(obj);
|
||||
|
@ -48,7 +48,7 @@ fn all_sprites(gfx: &ObjectController) {
|
|||
let objs_len = objs.len();
|
||||
for (i, obj) in objs.iter_mut().enumerate() {
|
||||
let this_image = (image + i * SPRITES.len() / objs_len) % SPRITES.len();
|
||||
obj.set_sprite(gfx.get_sprite(&SPRITES[this_image]));
|
||||
obj.set_sprite(gfx.sprite(&SPRITES[this_image]));
|
||||
obj.commit();
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ fn all_tags(gfx: &ObjectController) {
|
|||
for (i, v) in TAG_MAP.values().enumerate() {
|
||||
let x = (i % 7) as i32;
|
||||
let y = (i / 7) as i32;
|
||||
let sprite = v.get_sprite(0);
|
||||
let sprite = v.sprite(0);
|
||||
let (size_x, size_y) = sprite.size().to_width_height();
|
||||
let (size_x, size_y) = (size_x as i32, size_y as i32);
|
||||
let mut obj = gfx.get_object(gfx.get_sprite(sprite));
|
||||
let mut obj = gfx.get_object(gfx.sprite(sprite));
|
||||
obj.show();
|
||||
obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2).into());
|
||||
objs.push((obj, v));
|
||||
|
@ -90,7 +90,7 @@ fn all_tags(gfx: &ObjectController) {
|
|||
if count % 5 == 0 {
|
||||
image += 1;
|
||||
for (obj, tag) in objs.iter_mut() {
|
||||
obj.set_sprite(gfx.get_sprite(tag.get_animation_sprite(image)));
|
||||
obj.set_sprite(gfx.sprite(tag.animation_sprite(image)));
|
||||
obj.commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,21 +164,21 @@ pub struct Tag {
|
|||
}
|
||||
|
||||
impl Tag {
|
||||
pub fn get_sprites(&self) -> &'static [Sprite] {
|
||||
pub fn sprites(&self) -> &'static [Sprite] {
|
||||
unsafe { slice::from_raw_parts(self.sprites, self.len) }
|
||||
}
|
||||
|
||||
pub fn get_sprite(&self, idx: usize) -> &'static Sprite {
|
||||
&self.get_sprites()[idx]
|
||||
pub fn sprite(&self, idx: usize) -> &'static Sprite {
|
||||
&self.sprites()[idx]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_animation_sprite(&self, idx: usize) -> &'static Sprite {
|
||||
pub fn animation_sprite(&self, idx: usize) -> &'static Sprite {
|
||||
let len_sub_1 = self.len - 1;
|
||||
match self.direction {
|
||||
Direction::Forward => self.get_sprite(idx % self.len),
|
||||
Direction::Backward => self.get_sprite(len_sub_1 - (idx % self.len)),
|
||||
Direction::Pingpong => self.get_sprite(
|
||||
Direction::Forward => self.sprite(idx % self.len),
|
||||
Direction::Backward => self.sprite(len_sub_1 - (idx % self.len)),
|
||||
Direction::Pingpong => self.sprite(
|
||||
(((idx + len_sub_1) % (len_sub_1 * 2)) as isize - len_sub_1 as isize).abs()
|
||||
as usize,
|
||||
),
|
||||
|
@ -375,7 +375,7 @@ impl ObjectController {
|
|||
let mut attrs = Attributes::new();
|
||||
|
||||
attrs.a2.set_tile_index(sprite.sprite_location);
|
||||
let shape_size = sprite.id.get_sprite().size.shape_size();
|
||||
let shape_size = sprite.id.sprite().size.shape_size();
|
||||
attrs.a2.set_palete_bank(sprite.palette_location as u8);
|
||||
attrs.a0.set_shape(shape_size.0);
|
||||
attrs.a1a.set_size(shape_size.1);
|
||||
|
@ -389,7 +389,7 @@ impl ObjectController {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_sprite(&self, sprite: &'static Sprite) -> SpriteBorrow {
|
||||
pub fn sprite(&self, sprite: &'static Sprite) -> SpriteBorrow {
|
||||
self.sprite_controller
|
||||
.try_get_sprite(sprite)
|
||||
.expect("No slot for sprite available")
|
||||
|
@ -410,7 +410,7 @@ impl Drop for Object<'_, '_> {
|
|||
impl<'a, 'b> Object<'a, 'b> {
|
||||
pub fn set_sprite(&'_ mut self, sprite: SpriteBorrow<'a>) {
|
||||
self.attrs.a2.set_tile_index(sprite.sprite_location);
|
||||
let shape_size = sprite.id.get_sprite().size.shape_size();
|
||||
let shape_size = sprite.id.sprite().size.shape_size();
|
||||
self.attrs.a2.set_palete_bank(sprite.palette_location as u8);
|
||||
self.attrs.a0.set_shape(shape_size.0);
|
||||
self.attrs.a1a.set_size(shape_size.1);
|
||||
|
@ -496,7 +496,7 @@ impl<'a, 'b> Object<'a, 'b> {
|
|||
struct SpriteId(usize);
|
||||
|
||||
impl SpriteId {
|
||||
fn get_sprite(self) -> &'static Sprite {
|
||||
fn sprite(self) -> &'static Sprite {
|
||||
// # Safety
|
||||
// This must be constructed using the get_id of a sprite, so
|
||||
// they are always valid and always static
|
||||
|
@ -658,7 +658,7 @@ impl SpriteControllerInner {
|
|||
impl<'a> Drop for SpriteBorrow<'a> {
|
||||
fn drop(&mut self) {
|
||||
let mut inner = self.controller.borrow_mut();
|
||||
inner.return_sprite(self.id.get_sprite())
|
||||
inner.return_sprite(self.id.sprite())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ impl<'a> Clone for SpriteBorrow<'a> {
|
|||
fn clone(&self) -> Self {
|
||||
let mut inner = self.controller.borrow_mut();
|
||||
inner.sprite.entry(self.id).and_modify(|a| a.count += 1);
|
||||
let _ = inner.get_palette(self.id.get_sprite().palette).unwrap();
|
||||
let _ = inner.get_palette(self.id.sprite().palette).unwrap();
|
||||
Self {
|
||||
id: self.id,
|
||||
sprite_location: self.sprite_location,
|
||||
|
|
|
@ -23,12 +23,8 @@ fn main(mut gba: Gba) -> ! {
|
|||
let object = gba.display.object.get();
|
||||
|
||||
const BALL: &Tag = GRAPHICS.tags().get("Ball");
|
||||
let ball_sprite = object
|
||||
.try_get_sprite(BALL.get_sprite(0))
|
||||
.expect("We should be able to load a sprite");
|
||||
let mut ball = object
|
||||
.try_get_object(ball_sprite)
|
||||
.expect("We should have enoguh space to store an object");
|
||||
let ball_sprite = object.sprite(BALL.sprite(0));
|
||||
let mut ball = object.get_object(ball_sprite);
|
||||
|
||||
ball.set_x(50).set_y(50).show();
|
||||
|
||||
|
|
|
@ -164,8 +164,8 @@ impl<'a> Slime<'a> {
|
|||
SlimeState::Idle => {
|
||||
let offset = (timer / 16) as usize;
|
||||
|
||||
let frame = SLIME_IDLE.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SLIME_IDLE.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -204,8 +204,8 @@ impl<'a> Slime<'a> {
|
|||
self.enemy_info.entity.velocity = (0, 0).into();
|
||||
self.state = SlimeState::Idle;
|
||||
} else {
|
||||
let frame = SLIME_JUMP.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SLIME_JUMP.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
}
|
||||
|
@ -230,8 +230,8 @@ impl<'a> Slime<'a> {
|
|||
return UpdateState::Remove;
|
||||
}
|
||||
|
||||
let frame = SLIME_SPLAT.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SLIME_SPLAT.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
}
|
||||
|
@ -301,8 +301,8 @@ impl<'a> Snail<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let frame = SNAIL_IDLE.get_animation_sprite(0);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SNAIL_IDLE.animation_sprite(0);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
if player_has_collided {
|
||||
|
@ -321,8 +321,8 @@ impl<'a> Snail<'a> {
|
|||
}
|
||||
self.enemy_info.entity.velocity = (0, 0).into();
|
||||
|
||||
let frame = SNAIL_EMERGE.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SNAIL_EMERGE.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -343,8 +343,8 @@ impl<'a> Snail<'a> {
|
|||
|
||||
let offset = (timer - time) as usize / 8;
|
||||
|
||||
let frame = SNAIL_MOVE.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SNAIL_MOVE.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -377,8 +377,8 @@ impl<'a> Snail<'a> {
|
|||
self.state = SnailState::Idle(timer);
|
||||
}
|
||||
|
||||
let frame = SNAIL_EMERGE.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = SNAIL_EMERGE.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||
self.enemy_info.entity.velocity = (0, 0).into();
|
||||
|
@ -398,16 +398,16 @@ impl<'a> Snail<'a> {
|
|||
|
||||
let offset = (timer - time) as usize / 4;
|
||||
let frame = if offset < 5 {
|
||||
SNAIL_EMERGE.get_animation_sprite(5 - offset)
|
||||
SNAIL_EMERGE.animation_sprite(5 - offset)
|
||||
} else if offset == 5 {
|
||||
SNAIL_IDLE.get_animation_sprite(0)
|
||||
SNAIL_IDLE.animation_sprite(0)
|
||||
} else if offset < 5 + 7 {
|
||||
SNAIL_DEATH.get_animation_sprite(offset - 5)
|
||||
SNAIL_DEATH.animation_sprite(offset - 5)
|
||||
} else {
|
||||
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();
|
||||
|
|
|
@ -119,7 +119,7 @@ pub struct Entity<'a> {
|
|||
|
||||
impl<'a> Entity<'a> {
|
||||
pub fn new(object: &'a ObjectController, collision_mask: Vector2D<u16>) -> Self {
|
||||
let dummy_sprite = object.get_sprite(WALKING.get_sprite(0));
|
||||
let dummy_sprite = object.sprite(WALKING.sprite(0));
|
||||
let mut sprite = object.get_object(dummy_sprite);
|
||||
sprite.set_priority(Priority::P1);
|
||||
Entity {
|
||||
|
@ -349,9 +349,9 @@ impl<'a> Player<'a> {
|
|||
|
||||
wizard
|
||||
.sprite
|
||||
.set_sprite(controller.get_sprite(HAT_SPIN_1.get_sprite(0)));
|
||||
.set_sprite(controller.sprite(HAT_SPIN_1.sprite(0)));
|
||||
hat.sprite
|
||||
.set_sprite(controller.get_sprite(HAT_SPIN_1.get_sprite(0)));
|
||||
.set_sprite(controller.sprite(HAT_SPIN_1.sprite(0)));
|
||||
|
||||
wizard.sprite.show();
|
||||
hat.sprite.show();
|
||||
|
@ -456,8 +456,8 @@ impl<'a> Player<'a> {
|
|||
let offset = (ping_pong(timer / 16, 4)) as usize;
|
||||
self.wizard_frame = offset as u8;
|
||||
|
||||
let frame = WALKING.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = WALKING.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.wizard.sprite.set_sprite(sprite);
|
||||
}
|
||||
|
@ -466,8 +466,8 @@ impl<'a> Player<'a> {
|
|||
// going up
|
||||
self.wizard_frame = 5;
|
||||
|
||||
let frame = JUMPING.get_animation_sprite(0);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = JUMPING.animation_sprite(0);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.wizard.sprite.set_sprite(sprite);
|
||||
} else if self.wizard.velocity.y > FixedNumberType::new(1) / 16 {
|
||||
|
@ -481,8 +481,8 @@ impl<'a> Player<'a> {
|
|||
|
||||
self.wizard_frame = 0;
|
||||
|
||||
let frame = FALLING.get_animation_sprite(offset);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = FALLING.animation_sprite(offset);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.wizard.sprite.set_sprite(sprite);
|
||||
}
|
||||
|
@ -503,13 +503,13 @@ impl<'a> Player<'a> {
|
|||
self.wizard.sprite.set_hflip(true);
|
||||
self.hat
|
||||
.sprite
|
||||
.set_sprite(controller.get_sprite(hat_base_tile.get_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.get_sprite(0)));
|
||||
.set_sprite(controller.sprite(hat_base_tile.sprite(0)));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -541,7 +541,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.get_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() {
|
||||
|
@ -574,7 +574,7 @@ impl<'a> Player<'a> {
|
|||
}
|
||||
HatState::WizardTowards => {
|
||||
self.hat.sprite.set_sprite(
|
||||
controller.get_sprite(hat_base_tile.get_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;
|
||||
|
@ -676,8 +676,8 @@ impl<'a, 'b, 'c> PlayingLevel<'a, 'b> {
|
|||
fn dead_update(&mut self, controller: &'a ObjectController) -> bool {
|
||||
self.timer += 1;
|
||||
|
||||
let frame = PLAYER_DEATH.get_animation_sprite(self.timer as usize / 8);
|
||||
let sprite = controller.get_sprite(frame);
|
||||
let frame = PLAYER_DEATH.animation_sprite(self.timer as usize / 8);
|
||||
let sprite = controller.sprite(frame);
|
||||
|
||||
self.player.wizard.velocity += (0.into(), FixedNumberType::new(1) / 32).into();
|
||||
self.player.wizard.position += self.player.wizard.velocity;
|
||||
|
|
|
@ -161,7 +161,7 @@ struct Entity<'a> {
|
|||
|
||||
impl<'a> Entity<'a> {
|
||||
fn new(object_controller: &'a ObjectController, collision_mask: Rect<u16>) -> Self {
|
||||
let s = object_controller.get_sprite(LONGSWORD_IDLE.get_sprite(0));
|
||||
let s = object_controller.sprite(LONGSWORD_IDLE.sprite(0));
|
||||
let mut sprite = object_controller.get_object(s);
|
||||
sprite.set_priority(Priority::P1);
|
||||
Entity {
|
||||
|
@ -350,10 +350,10 @@ impl SwordState {
|
|||
fn idle_animation(self, counter: u16) -> &'static Sprite {
|
||||
let counter = counter as usize;
|
||||
match self {
|
||||
SwordState::LongSword => LONGSWORD_IDLE.get_animation_sprite(counter / 8),
|
||||
SwordState::ShortSword => SHORTSWORD_IDLE.get_animation_sprite(counter / 8),
|
||||
SwordState::Dagger => KNIFE_IDLE.get_animation_sprite(counter / 8),
|
||||
SwordState::Swordless => SWORDLESS_IDLE.get_animation_sprite(counter / 8),
|
||||
SwordState::LongSword => LONGSWORD_IDLE.animation_sprite(counter / 8),
|
||||
SwordState::ShortSword => SHORTSWORD_IDLE.animation_sprite(counter / 8),
|
||||
SwordState::Dagger => KNIFE_IDLE.animation_sprite(counter / 8),
|
||||
SwordState::Swordless => SWORDLESS_IDLE.animation_sprite(counter / 8),
|
||||
}
|
||||
}
|
||||
fn jump_tag(self) -> &'static Tag {
|
||||
|
@ -367,10 +367,10 @@ impl SwordState {
|
|||
fn walk_animation(self, counter: u16) -> &'static Sprite {
|
||||
let counter = counter as usize;
|
||||
match self {
|
||||
SwordState::LongSword => LONGSWORD_WALK.get_animation_sprite(counter / 4),
|
||||
SwordState::ShortSword => SHORTSWORD_WALK.get_animation_sprite(counter / 4),
|
||||
SwordState::Dagger => KNIFE_WALK.get_animation_sprite(counter / 4),
|
||||
SwordState::Swordless => SWORDLESS_WALK.get_animation_sprite(counter / 4),
|
||||
SwordState::LongSword => LONGSWORD_WALK.animation_sprite(counter / 4),
|
||||
SwordState::ShortSword => SHORTSWORD_WALK.animation_sprite(counter / 4),
|
||||
SwordState::Dagger => KNIFE_WALK.animation_sprite(counter / 4),
|
||||
SwordState::Swordless => SWORDLESS_WALK.animation_sprite(counter / 4),
|
||||
}
|
||||
}
|
||||
fn attack_duration(self) -> u16 {
|
||||
|
@ -536,7 +536,7 @@ impl<'a> Player<'a> {
|
|||
object_controller,
|
||||
Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()),
|
||||
);
|
||||
let s = object_controller.get_sprite(LONGSWORD_IDLE.get_sprite(0));
|
||||
let s = object_controller.sprite(LONGSWORD_IDLE.sprite(0));
|
||||
entity.sprite.set_sprite(s);
|
||||
entity.sprite.show();
|
||||
entity.position = (144, 0).into();
|
||||
|
@ -590,12 +590,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);
|
||||
}
|
||||
|
||||
|
@ -615,8 +615,7 @@ impl<'a> Player<'a> {
|
|||
let frame = self.sword.attack_frame(*a);
|
||||
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
|
||||
let tag = self.sword.attack_tag();
|
||||
let sprite =
|
||||
controller.get_sprite(tag.get_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);
|
||||
|
@ -630,8 +629,7 @@ impl<'a> Player<'a> {
|
|||
let frame = self.sword.hold_frame();
|
||||
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
|
||||
let tag = self.sword.attack_tag();
|
||||
let sprite =
|
||||
controller.get_sprite(tag.get_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;
|
||||
|
@ -656,8 +654,7 @@ impl<'a> Player<'a> {
|
|||
2
|
||||
};
|
||||
let tag = self.sword.jump_tag();
|
||||
let sprite =
|
||||
controller.get_sprite(tag.get_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 {
|
||||
|
@ -679,8 +676,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.get_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);
|
||||
|
@ -842,8 +838,8 @@ impl BatData {
|
|||
sfx.bat_flap();
|
||||
}
|
||||
|
||||
let sprite = BAT_IDLE.get_sprite(self.sprite_offset as usize / 8);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 8);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -877,8 +873,8 @@ impl BatData {
|
|||
self.sprite_offset = 0;
|
||||
}
|
||||
|
||||
let sprite = BAT_IDLE.get_sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -904,8 +900,8 @@ impl BatData {
|
|||
}
|
||||
BatState::Dead => {
|
||||
const BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
|
||||
let sprite = BAT_DEAD.get_sprite(0);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = BAT_DEAD.sprite(0);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -972,8 +968,8 @@ impl SlimeData {
|
|||
|
||||
const IDLE: &Tag = TAG_MAP.get("slime idle");
|
||||
|
||||
let sprite = IDLE.get_sprite(self.sprite_offset as usize / 16);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -1012,8 +1008,8 @@ impl SlimeData {
|
|||
|
||||
const CHASE: &Tag = TAG_MAP.get("Slime jump");
|
||||
|
||||
let sprite = CHASE.get_sprite(frame as usize);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = CHASE.sprite(frame as usize);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -1042,8 +1038,8 @@ impl SlimeData {
|
|||
SlimeState::Dead(count) => {
|
||||
if *count < 5 * 4 {
|
||||
const DEATH: &Tag = TAG_MAP.get("Slime death");
|
||||
let sprite = DEATH.get_sprite(*count as usize / 4);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = DEATH.sprite(*count as usize / 4);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
*count += 1;
|
||||
|
@ -1110,8 +1106,8 @@ impl MiniFlameData {
|
|||
entity.velocity = resulting_direction.normalise() * Number::new(2);
|
||||
}
|
||||
} else {
|
||||
let sprite = ANGRY.get_animation_sprite(self.sprite_offset as usize / 8);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 8);
|
||||
let sprite = controller.sprite(sprite);
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
entity.velocity = (0.into(), Number::new(-1) / Number::new(4)).into();
|
||||
|
@ -1158,8 +1154,8 @@ impl MiniFlameData {
|
|||
self.state = MiniFlameState::Idle(90);
|
||||
}
|
||||
|
||||
let sprite = ANGRY.get_animation_sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.sprite(sprite);
|
||||
entity.sprite.set_sprite(sprite);
|
||||
}
|
||||
MiniFlameState::Dead => {
|
||||
|
@ -1170,8 +1166,8 @@ impl MiniFlameData {
|
|||
|
||||
const DEATH: &Tag = TAG_MAP.get("angry boss dead");
|
||||
|
||||
let sprite = DEATH.get_animation_sprite(self.sprite_offset as usize / 12);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12);
|
||||
let sprite = controller.sprite(sprite);
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
self.sprite_offset += 1;
|
||||
|
@ -1231,8 +1227,8 @@ impl EmuData {
|
|||
|
||||
const IDLE: &Tag = TAG_MAP.get("emu - idle");
|
||||
|
||||
let sprite = IDLE.get_sprite(self.sprite_offset as usize / 16);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
||||
let sprite = controller.sprite(sprite);
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
if (entity.position.y - player.entity.position.y).abs() < 10.into() {
|
||||
|
@ -1278,8 +1274,8 @@ impl EmuData {
|
|||
|
||||
const WALK: &Tag = TAG_MAP.get("emu-walk");
|
||||
|
||||
let sprite = WALK.get_sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = WALK.sprite(self.sprite_offset as usize / 2);
|
||||
let sprite = controller.sprite(sprite);
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
let gravity: Number = 1.into();
|
||||
|
@ -1333,8 +1329,8 @@ impl EmuData {
|
|||
|
||||
const DEATH: &Tag = TAG_MAP.get("emu - die");
|
||||
|
||||
let sprite = DEATH.get_animation_sprite(self.sprite_offset as usize / 4);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4);
|
||||
let sprite = controller.sprite(sprite);
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
self.sprite_offset += 1;
|
||||
|
@ -1370,10 +1366,10 @@ impl EnemyData {
|
|||
const MINI_FLAME: &Tag = TAG_MAP.get("angry boss");
|
||||
const EMU: &Tag = TAG_MAP.get("emu - idle");
|
||||
match self {
|
||||
EnemyData::Slime(_) => SLIME.get_sprite(0),
|
||||
EnemyData::Bat(_) => BAT.get_sprite(0),
|
||||
EnemyData::MiniFlame(_) => MINI_FLAME.get_sprite(0),
|
||||
EnemyData::Emu(_) => EMU.get_sprite(0),
|
||||
EnemyData::Slime(_) => SLIME.sprite(0),
|
||||
EnemyData::Bat(_) => BAT.sprite(0),
|
||||
EnemyData::MiniFlame(_) => MINI_FLAME.sprite(0),
|
||||
EnemyData::Emu(_) => EMU.sprite(0),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1400,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();
|
||||
|
@ -1467,8 +1463,8 @@ impl ParticleData {
|
|||
}
|
||||
|
||||
const DUST: &Tag = TAG_MAP.get("dust");
|
||||
let sprite = DUST.get_sprite(*frame as usize / 3);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = DUST.sprite(*frame as usize / 3);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -1481,8 +1477,8 @@ impl ParticleData {
|
|||
}
|
||||
|
||||
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||
let sprite = HEALTH.get_animation_sprite(*frame as usize / 3);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -1507,8 +1503,8 @@ impl ParticleData {
|
|||
}
|
||||
ParticleData::BossHealer(frame, target) => {
|
||||
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||
let sprite = HEALTH.get_animation_sprite(*frame as usize / 3);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -1671,8 +1667,8 @@ impl<'a> FollowingBoss<'a> {
|
|||
|
||||
const BOSS: &Tag = TAG_MAP.get("happy boss");
|
||||
|
||||
let sprite = BOSS.get_animation_sprite(frame as usize);
|
||||
let sprite = controller.get_sprite(sprite);
|
||||
let sprite = BOSS.animation_sprite(frame as usize);
|
||||
let sprite = controller.sprite(sprite);
|
||||
|
||||
self.entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
@ -1807,8 +1803,8 @@ impl<'a> Boss<'a> {
|
|||
|
||||
const BOSS: &Tag = TAG_MAP.get("Boss");
|
||||
|
||||
let sprite = BOSS.get_animation_sprite(frame as usize);
|
||||
let sprite = object_controller.get_sprite(sprite);
|
||||
let sprite = BOSS.animation_sprite(frame as usize);
|
||||
let sprite = object_controller.sprite(sprite);
|
||||
|
||||
self.entity.sprite.set_sprite(sprite);
|
||||
|
||||
|
|
Loading…
Reference in a new issue