diff --git a/agb/examples/affine_background.rs b/agb/examples/affine_background.rs index 5ac2e289..2e336b13 100644 --- a/agb/examples/affine_background.rs +++ b/agb/examples/affine_background.rs @@ -6,7 +6,7 @@ use agb::{ tiled::{AffineBackgroundSize, TileFormat, TileSet, TiledMap}, Priority, }, - fixnum::num, + fixnum::{num, Num}, include_gfx, input::Tri, }; @@ -33,7 +33,7 @@ fn main(mut gba: agb::Gba) -> ! { bg.commit(&mut vram); bg.show(); - let mut rotation = num!(0.); + let mut rotation: Num = num!(0.); let rotation_increase = num!(1.); let mut input = agb::input::ButtonController::new(); @@ -56,10 +56,12 @@ fn main(mut gba: agb::Gba) -> ! { _ => {} } + bg.set_scroll_pos((16 * 4, 16 * 4).into()); + let scroll_pos = (scroll_x as i16, scroll_y as i16); bg.set_transform( - (-scroll_x as i16, -scroll_y as i16).into(), - (1, 1).into(), - rotation, + scroll_pos, + (1, 1), + rotation, ); rotation += rotation_increase; diff --git a/agb/src/display/tiled/map.rs b/agb/src/display/tiled/map.rs index 7af1f57b..45b09646 100644 --- a/agb/src/display/tiled/map.rs +++ b/agb/src/display/tiled/map.rs @@ -284,10 +284,10 @@ impl TiledMapPrivate for AffineMap { &mut self.bg_center.y } fn x_scroll(&self) -> Self::Position { - self.bg_center.x + self.bg_center.x + self.transform.position.x } fn y_scroll(&self) -> Self::Position { - self.bg_center.y + self.bg_center.y + self.transform.position.y } fn affine_matrix(&self) -> Self::AffineMatrix { self.transform.matrix @@ -375,15 +375,15 @@ impl AffineMap { pub fn set_transform( &mut self, - display_center: Vector2D, - scale: Vector2D>, - rotation: Num, + display_center: impl Into>, + scale: impl Into>>, + rotation: impl Into>, ) { self.set_transform_raw(crate::syscall::bg_affine_matrix( self.bg_center, - display_center, - scale, - rotation, + display_center.into(), + scale.into(), + rotation.into(), )); } }