mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
Allow movement of the affine background
This commit is contained in:
parent
97e3948f32
commit
fcde651821
|
@ -38,24 +38,29 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
|
|
||||||
let mut input = agb::input::ButtonController::new();
|
let mut input = agb::input::ButtonController::new();
|
||||||
|
|
||||||
|
let mut scroll_x = 0;
|
||||||
|
let mut scroll_y = 0;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
input.update();
|
input.update();
|
||||||
|
|
||||||
let x_dir = match input.x_tri() {
|
match input.x_tri() {
|
||||||
Tri::Positive => (1, 0).into(),
|
Tri::Positive => scroll_x += 1,
|
||||||
Tri::Negative => (-1, 0).into(),
|
Tri::Negative => scroll_x -= 1,
|
||||||
_ => (0, 0).into(),
|
_ => {}
|
||||||
};
|
}
|
||||||
|
|
||||||
let y_dir = match input.y_tri() {
|
match input.y_tri() {
|
||||||
Tri::Positive => (0, 1).into(),
|
Tri::Positive => scroll_y += 1,
|
||||||
Tri::Negative => (0, -1).into(),
|
Tri::Negative => scroll_y -= 1,
|
||||||
_ => (0, 0).into(),
|
_ => {}
|
||||||
};
|
}
|
||||||
|
|
||||||
let new_scroll_pos = bg.scroll_pos() + x_dir + y_dir;
|
bg.set_transform(
|
||||||
bg.set_scroll_pos(new_scroll_pos);
|
(-scroll_x as i16, -scroll_y as i16).into(),
|
||||||
bg.set_transform((0i16, 0i16).into(), (1, 1).into(), rotation);
|
(1, 1).into(),
|
||||||
|
rotation,
|
||||||
|
);
|
||||||
|
|
||||||
rotation += rotation_increase;
|
rotation += rotation_increase;
|
||||||
if rotation >= num!(255.) {
|
if rotation >= num!(255.) {
|
||||||
|
|
Loading…
Reference in a new issue