diff --git a/agb/examples/affine_background.rs b/agb/examples/affine_background.rs index 18987def..f2b08bd0 100644 --- a/agb/examples/affine_background.rs +++ b/agb/examples/affine_background.rs @@ -26,7 +26,7 @@ fn main(mut gba: agb::Gba) -> ! { for y in 0..32u16 { for x in 0..32u16 { - bg.set_tile(&mut vram, (x, y).into(), &tileset, 1); + bg.set_tile(&mut vram, (x, y), &tileset, 1); } } @@ -46,14 +46,14 @@ fn main(mut gba: agb::Gba) -> ! { scroll_x += input.x_tri() as i32; scroll_y += input.y_tri() as i32; - let scroll_pos = (scroll_x, scroll_y).into(); + let scroll_pos = (scroll_x, scroll_y); rotation += rotation_increase; rotation = rotation.rem_euclid(1.into()); let transformation = AffineMatrixBackground::from_scale_rotation_position( - (0, 0).into(), - (1, 1).into(), + (0, 0), + (1, 1), rotation, scroll_pos, ); diff --git a/agb/examples/animated_background.rs b/agb/examples/animated_background.rs index 0064121a..9d6a5e07 100644 --- a/agb/examples/animated_background.rs +++ b/agb/examples/animated_background.rs @@ -30,7 +30,7 @@ fn main(mut gba: agb::Gba) -> ! { for x in 0..30u16 { bg.set_tile( &mut vram, - (x, y).into(), + (x, y), &tileset, water_tiles::water_tiles.tile_settings[0], ); diff --git a/agb/examples/chicken.rs b/agb/examples/chicken.rs index 9a247f0b..e8f41316 100644 --- a/agb/examples/chicken.rs +++ b/agb/examples/chicken.rs @@ -64,7 +64,7 @@ fn main(mut gba: agb::Gba) -> ! { let i = i as u16; background.set_tile( &mut vram, - (i % 32, i / 32).into(), + (i % 32, i / 32), &tileset, TileSetting::from_raw(tile), ); diff --git a/agb/examples/mixer_32768.rs b/agb/examples/mixer_32768.rs index 0593a72f..1129f959 100644 --- a/agb/examples/mixer_32768.rs +++ b/agb/examples/mixer_32768.rs @@ -31,7 +31,7 @@ fn main(mut gba: Gba) -> ! { init_background(&mut bg, &mut vram); - let mut title_renderer = FONT.render_text((0u16, 3u16).into()); + let mut title_renderer = FONT.render_text((0u16, 3u16)); let mut writer = title_renderer.writer(1, 0, &mut bg, &mut vram); writeln!(&mut writer, "Crazy Glue by Josh Woodward").unwrap(); @@ -57,7 +57,7 @@ fn main(mut gba: Gba) -> ! { let mut frame_counter = 0i32; let mut has_written_frame_time = false; - let mut stats_renderer = FONT.render_text((0u16, 6u16).into()); + let mut stats_renderer = FONT.render_text((0u16, 6u16)); loop { vblank_provider.wait_for_vblank(); bg.commit(&mut vram); @@ -106,7 +106,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) { for x in 0..30u16 { bg.set_tile( vram, - (x, y).into(), + (x, y), &background_tile.tile_set(), background_tile.tile_setting(), ); diff --git a/agb/examples/object_text_render.rs b/agb/examples/object_text_render.rs index f3df935a..22bb20a9 100644 --- a/agb/examples/object_text_render.rs +++ b/agb/examples/object_text_render.rs @@ -58,7 +58,7 @@ fn main(mut gba: agb::Gba) -> ! { let start = timer.value(); - wr.layout((WIDTH, 40).into(), TextAlignment::Justify, 2); + wr.layout((WIDTH, 40), TextAlignment::Justify, 2); let end = timer.value(); agb::println!( @@ -83,7 +83,7 @@ fn main(mut gba: agb::Gba) -> ! { line_done = false; wr.pop_line(); } - wr.update((0, HEIGHT - 40).into()); + wr.update((0, HEIGHT - 40)); let end = timer.value(); frame += 1; diff --git a/agb/examples/sprites.rs b/agb/examples/sprites.rs index 161e4ed8..679fea10 100644 --- a/agb/examples/sprites.rs +++ b/agb/examples/sprites.rs @@ -34,7 +34,7 @@ fn all_sprites(gfx: &OamManaged, rotation_speed: Num) { let mut obj = gfx.object_sprite(&SPRITES[0]); obj.set_affine_matrix(matrix.clone()); 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)); objs.push(obj); } } @@ -87,7 +87,7 @@ fn all_tags(gfx: &OamManaged) { let (size_x, size_y) = (size_x as i32, size_y as i32); let mut obj = gfx.object_sprite(sprite); 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)); objs.push((obj, v)); } diff --git a/agb/examples/stereo_sound.rs b/agb/examples/stereo_sound.rs index ba0fe025..9e1be011 100644 --- a/agb/examples/stereo_sound.rs +++ b/agb/examples/stereo_sound.rs @@ -31,7 +31,7 @@ fn main(mut gba: Gba) -> ! { init_background(&mut bg, &mut vram); - let mut title_renderer = FONT.render_text((0u16, 3u16).into()); + let mut title_renderer = FONT.render_text((0u16, 3u16)); let mut writer = title_renderer.writer(1, 0, &mut bg, &mut vram); writeln!(&mut writer, "Let it in by Josh Woodward").unwrap(); @@ -55,7 +55,7 @@ fn main(mut gba: Gba) -> ! { let mut frame_counter = 0i32; let mut has_written_frame_time = false; - let mut stats_renderer = FONT.render_text((0u16, 6u16).into()); + let mut stats_renderer = FONT.render_text((0u16, 6u16)); loop { vblank_provider.wait_for_vblank(); bg.commit(&mut vram); @@ -94,7 +94,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) { for x in 0..30u16 { bg.set_tile( vram, - (x, y).into(), + (x, y), &background_tile.tile_set(), background_tile.tile_setting(), ); diff --git a/agb/examples/text_render.rs b/agb/examples/text_render.rs index d2f91189..350b80a5 100644 --- a/agb/examples/text_render.rs +++ b/agb/examples/text_render.rs @@ -35,7 +35,7 @@ fn main(mut gba: agb::Gba) -> ! { for x in 0..30u16 { bg.set_tile( &mut vram, - (x, y).into(), + (x, y), &background_tile.tile_set(), background_tile.tile_setting(), ); @@ -44,7 +44,7 @@ fn main(mut gba: agb::Gba) -> ! { vram.remove_dynamic_tile(background_tile); - let mut renderer = FONT.render_text((0u16, 3u16).into()); + let mut renderer = FONT.render_text((0u16, 3u16)); let mut writer = renderer.writer(1, 2, &mut bg, &mut vram); writeln!(&mut writer, "Hello, World!").unwrap(); @@ -58,7 +58,7 @@ fn main(mut gba: agb::Gba) -> ! { let mut frame = 0; loop { - let mut renderer = FONT.render_text((4u16, 0u16).into()); + let mut renderer = FONT.render_text((4u16, 0u16)); let mut writer = renderer.writer(1, 2, &mut bg, &mut vram); writeln!(&mut writer, "Frame {frame}").unwrap(); diff --git a/agb/src/display/affine.rs b/agb/src/display/affine.rs index bddb6fa6..008b58ad 100644 --- a/agb/src/display/affine.rs +++ b/agb/src/display/affine.rs @@ -295,15 +295,15 @@ impl AffineMatrixBackground { /// # } /// ``` pub fn from_scale_rotation_position( - transform_origin: Vector2D>, - scale: Vector2D>, + transform_origin: impl Into>>, + scale: impl Into>>, rotation: Num, - position: Vector2D>, + position: impl Into>>, ) -> Self { crate::syscall::bg_affine_matrix( - transform_origin, - position.try_change_base::().unwrap().floor(), - scale.try_change_base().unwrap(), + transform_origin.into(), + position.into().try_change_base::().unwrap().floor(), + scale.into().try_change_base().unwrap(), rotation.rem_euclid(1.into()).try_change_base().unwrap(), ) } diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index aef42ce2..54b3078f 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -78,12 +78,12 @@ impl Font { impl Font { #[must_use] /// Create renderer starting at the given tile co-ordinates. - pub fn render_text(&self, tile_pos: Vector2D) -> TextRenderer<'_> { + pub fn render_text(&self, tile_pos: impl Into>) -> TextRenderer<'_> { TextRenderer { current_x_pos: 0, current_y_pos: 0, font: self, - tile_pos, + tile_pos: tile_pos.into(), tiles: Default::default(), } } @@ -292,7 +292,7 @@ mod tests { for x in 0..30u16 { bg.set_tile( &mut vram, - (x, y).into(), + (x, y), &background_tile.tile_set(), background_tile.tile_setting(), ); @@ -301,7 +301,7 @@ mod tests { vram.remove_dynamic_tile(background_tile); - let mut renderer = FONT.render_text((0u16, 3u16).into()); + let mut renderer = FONT.render_text((0u16, 3u16)); // Test twice to ensure that clearing works for _ in 0..2 { diff --git a/agb/src/display/object/font.rs b/agb/src/display/object/font.rs index a9d05da5..f7a03b41 100644 --- a/agb/src/display/object/font.rs +++ b/agb/src/display/object/font.rs @@ -229,11 +229,11 @@ impl BufferedRender<'_> { /// let mut writer = ObjectTextRender::new(&EXAMPLE_FONT, Size::S16x16, palette); /// /// let _ = writeln!(writer, "Hello, World!"); -/// writer.layout((WIDTH, 40).into(), TextAlignment::Left, 2); +/// writer.layout((WIDTH, 40), TextAlignment::Left, 2); /// /// loop { /// writer.next_letter_group(); -/// writer.update((0, 0).into()); +/// writer.update((0, 0)); /// vblank.wait_for_vblank(); /// let oam = &mut unmanaged.iter(); /// writer.commit(oam); @@ -287,7 +287,7 @@ impl ObjectTextRender<'_> { /// Force a relayout, must be called after writing. pub fn layout( &mut self, - area: Vector2D, + area: impl Into>, alignment: TextAlignment, paragraph_spacing: i32, ) { @@ -295,7 +295,7 @@ impl ObjectTextRender<'_> { self.buffer.font, &self.buffer.preprocessor, &LayoutSettings { - area, + area: area.into(), alignment, paragraph_spacing, }, @@ -331,7 +331,7 @@ impl ObjectTextRender<'_> { /// Updates the internal state of the number of letters to write and popped /// line. Should be called in the same frame as and after /// [`next_letter_group`][ObjectTextRender::next_letter_group], [`next_line`][ObjectTextRender::next_line], and [`pop_line`][ObjectTextRender::pop_line]. - pub fn update(&mut self, position: Vector2D) { + pub fn update(&mut self, position: impl Into>) { if !self.buffer.buffered_chars.is_empty() && self.buffer.letters.letters.len() <= self.number_of_objects + 5 { @@ -339,7 +339,7 @@ impl ObjectTextRender<'_> { } self.layout.update_objects_to_display_at_position( - position, + position.into(), self.buffer.letters.letters.iter(), self.number_of_objects, ); diff --git a/agb/src/display/object/managed.rs b/agb/src/display/object/managed.rs index fca35daa..11b8bb38 100644 --- a/agb/src/display/object/managed.rs +++ b/agb/src/display/object/managed.rs @@ -489,9 +489,9 @@ impl Object<'_> { /// Sets the position of the object. /// Use [position](Self::position) to get the value - pub fn set_position(&mut self, position: Vector2D) -> &mut Self { + pub fn set_position(&mut self, position: impl Into>) -> &mut Self { // safety: only have one of these, doesn't modify slotmap - unsafe { self.object().set_position(position) }; + unsafe { self.object().set_position(position.into()) }; self } diff --git a/agb/src/display/tiled/map.rs b/agb/src/display/tiled/map.rs index 66b7f560..4a52644f 100644 --- a/agb/src/display/tiled/map.rs +++ b/agb/src/display/tiled/map.rs @@ -377,11 +377,11 @@ impl AffineMap { pub fn set_tile( &mut self, vram: &mut VRamManager, - pos: Vector2D, + pos: impl Into>, tileset: &TileSet<'_>, tile_id: u8, ) { - let pos = self.map_size().gba_offset(pos); + let pos = self.map_size().gba_offset(pos.into()); let colours = self.colours(); let old_tile = self.tiles_mut()[pos]; diff --git a/agb/src/lib.rs b/agb/src/lib.rs index 8c9e9062..abc31960 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -87,7 +87,7 @@ /// for x in 0..30u16 { /// bg.set_tile( /// &mut vram, -/// (x, y).into(), +/// (x, y), /// &tileset, /// water_tiles::tiles.tile_settings[0], /// ); diff --git a/examples/hyperspace-roll/src/battle/display.rs b/examples/hyperspace-roll/src/battle/display.rs index fbc1cd88..94577f1b 100644 --- a/examples/hyperspace-roll/src/battle/display.rs +++ b/examples/hyperspace-roll/src/battle/display.rs @@ -1,4 +1,5 @@ use agb::display::object::{OamManaged, Object}; +use agb::fixnum::Vector2D; use agb::rng; use alloc::vec; use alloc::vec::Vec; @@ -149,7 +150,7 @@ impl<'a> BattleScreenDisplay<'a> { let mut attack_obj = obj .object_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(EnemyAttackType::Attack)); - let attack_obj_position = (120, 56 + 32 * i).into(); + let attack_obj_position = Vector2D::new(120, 56 + 32 * i); attack_obj.set_position(attack_obj_position).hide(); let mut attack_cooldown =