mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Make the example work the way I expect it to
This commit is contained in:
parent
496b4a4953
commit
59673206b3
|
@ -6,7 +6,7 @@ use agb::{
|
||||||
tiled::{AffineBackgroundSize, TileFormat, TileSet, TiledMap},
|
tiled::{AffineBackgroundSize, TileFormat, TileSet, TiledMap},
|
||||||
Priority,
|
Priority,
|
||||||
},
|
},
|
||||||
fixnum::num,
|
fixnum::{num, Num},
|
||||||
include_gfx,
|
include_gfx,
|
||||||
input::Tri,
|
input::Tri,
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
bg.commit(&mut vram);
|
bg.commit(&mut vram);
|
||||||
bg.show();
|
bg.show();
|
||||||
|
|
||||||
let mut rotation = num!(0.);
|
let mut rotation: Num<u16, 8> = num!(0.);
|
||||||
let rotation_increase = num!(1.);
|
let rotation_increase = num!(1.);
|
||||||
|
|
||||||
let mut input = agb::input::ButtonController::new();
|
let mut input = agb::input::ButtonController::new();
|
||||||
|
@ -56,9 +56,11 @@ 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(
|
bg.set_transform(
|
||||||
(-scroll_x as i16, -scroll_y as i16).into(),
|
scroll_pos,
|
||||||
(1, 1).into(),
|
(1, 1),
|
||||||
rotation,
|
rotation,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -284,10 +284,10 @@ impl TiledMapPrivate for AffineMap {
|
||||||
&mut self.bg_center.y
|
&mut self.bg_center.y
|
||||||
}
|
}
|
||||||
fn x_scroll(&self) -> Self::Position {
|
fn x_scroll(&self) -> Self::Position {
|
||||||
self.bg_center.x
|
self.bg_center.x + self.transform.position.x
|
||||||
}
|
}
|
||||||
fn y_scroll(&self) -> Self::Position {
|
fn y_scroll(&self) -> Self::Position {
|
||||||
self.bg_center.y
|
self.bg_center.y + self.transform.position.y
|
||||||
}
|
}
|
||||||
fn affine_matrix(&self) -> Self::AffineMatrix {
|
fn affine_matrix(&self) -> Self::AffineMatrix {
|
||||||
self.transform.matrix
|
self.transform.matrix
|
||||||
|
@ -375,15 +375,15 @@ impl AffineMap {
|
||||||
|
|
||||||
pub fn set_transform(
|
pub fn set_transform(
|
||||||
&mut self,
|
&mut self,
|
||||||
display_center: Vector2D<i16>,
|
display_center: impl Into<Vector2D<i16>>,
|
||||||
scale: Vector2D<Num<i16, 8>>,
|
scale: impl Into<Vector2D<Num<i16, 8>>>,
|
||||||
rotation: Num<u16, 8>,
|
rotation: impl Into<Num<u16, 8>>,
|
||||||
) {
|
) {
|
||||||
self.set_transform_raw(crate::syscall::bg_affine_matrix(
|
self.set_transform_raw(crate::syscall::bg_affine_matrix(
|
||||||
self.bg_center,
|
self.bg_center,
|
||||||
display_center,
|
display_center.into(),
|
||||||
scale,
|
scale.into(),
|
||||||
rotation,
|
rotation.into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue