Rename get_object to object

This commit is contained in:
Gwilym Kuiper 2022-03-23 20:34:55 +00:00
parent 5791d033ef
commit 3e34509049
6 changed files with 7 additions and 7 deletions

View file

@ -74,7 +74,7 @@ fn main(mut gba: agb::Gba) -> ! {
let sprite = object.sprite(&ChickenSprites[0]); let sprite = object.sprite(&ChickenSprites[0]);
let mut chicken = Character { let mut chicken = Character {
object: object.get_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,

View file

@ -20,7 +20,7 @@ fn all_sprites(gfx: &ObjectController) {
for y in 0..9 { for y in 0..9 {
for x in 0..14 { for x in 0..14 {
let mut obj = gfx.get_object(gfx.sprite(&SPRITES[0])); let mut obj = gfx.object(gfx.sprite(&SPRITES[0]));
obj.show(); obj.show();
obj.set_position((x * 16 + 8, y * 16 + 8).into()); obj.set_position((x * 16 + 8, y * 16 + 8).into());
objs.push(obj); objs.push(obj);
@ -65,7 +65,7 @@ fn all_tags(gfx: &ObjectController) {
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.get_object(gfx.sprite(sprite)); let mut obj = gfx.object(gfx.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));

View file

@ -361,7 +361,7 @@ impl ObjectController {
} }
} }
pub fn get_object<'a, 'b>(&'a self, sprite: SpriteBorrow<'b>) -> Object<'b, 'a> { pub fn object<'a, 'b>(&'a self, sprite: SpriteBorrow<'b>) -> Object<'b, 'a> {
self.try_get_object(sprite).expect("No object available") self.try_get_object(sprite).expect("No object available")
} }

View file

@ -24,7 +24,7 @@ fn main(mut gba: Gba) -> ! {
const BALL: &Tag = GRAPHICS.tags().get("Ball"); const BALL: &Tag = GRAPHICS.tags().get("Ball");
let ball_sprite = object.sprite(BALL.sprite(0)); let ball_sprite = object.sprite(BALL.sprite(0));
let mut ball = object.get_object(ball_sprite); let mut ball = object.object(ball_sprite);
ball.set_x(50).set_y(50).show(); ball.set_x(50).set_y(50).show();

View file

@ -120,7 +120,7 @@ pub struct Entity<'a> {
impl<'a> Entity<'a> { impl<'a> Entity<'a> {
pub fn new(object: &'a ObjectController, collision_mask: Vector2D<u16>) -> Self { pub fn new(object: &'a ObjectController, collision_mask: Vector2D<u16>) -> Self {
let dummy_sprite = object.sprite(WALKING.sprite(0)); let dummy_sprite = object.sprite(WALKING.sprite(0));
let mut sprite = object.get_object(dummy_sprite); let mut sprite = object.object(dummy_sprite);
sprite.set_priority(Priority::P1); sprite.set_priority(Priority::P1);
Entity { Entity {
sprite, sprite,

View file

@ -162,7 +162,7 @@ struct Entity<'a> {
impl<'a> Entity<'a> { impl<'a> Entity<'a> {
fn new(object_controller: &'a ObjectController, collision_mask: Rect<u16>) -> Self { fn new(object_controller: &'a ObjectController, collision_mask: Rect<u16>) -> Self {
let s = object_controller.sprite(LONGSWORD_IDLE.sprite(0)); let s = object_controller.sprite(LONGSWORD_IDLE.sprite(0));
let mut sprite = object_controller.get_object(s); let mut sprite = object_controller.object(s);
sprite.set_priority(Priority::P1); sprite.set_priority(Priority::P1);
Entity { Entity {
sprite, sprite,