2021-03-07 04:58:59 +11:00
|
|
|
#![no_std]
|
2021-05-23 06:22:44 +10:00
|
|
|
#![no_main]
|
2021-03-07 04:58:59 +11:00
|
|
|
|
2021-04-16 07:10:00 +10:00
|
|
|
extern crate agb;
|
2021-03-07 04:58:59 +11:00
|
|
|
|
2021-04-16 07:10:00 +10:00
|
|
|
use agb::display;
|
2021-03-07 04:58:59 +11:00
|
|
|
|
|
|
|
struct Vector2D {
|
|
|
|
x: i32,
|
|
|
|
y: i32,
|
|
|
|
}
|
|
|
|
|
2021-08-08 01:36:41 +10:00
|
|
|
#[agb::entry]
|
|
|
|
fn main() -> ! {
|
2021-04-16 07:10:00 +10:00
|
|
|
let mut gba = agb::Gba::new();
|
2021-03-08 12:59:05 +11:00
|
|
|
let mut bitmap = gba.display.video.bitmap3();
|
2021-07-04 03:57:17 +10:00
|
|
|
let vblank = agb::interrupt::VBlank::get();
|
2021-03-07 04:58:59 +11:00
|
|
|
|
2021-04-16 07:10:00 +10:00
|
|
|
let mut input = agb::input::ButtonController::new();
|
2021-03-07 04:58:59 +11:00
|
|
|
let mut pos = Vector2D {
|
|
|
|
x: display::WIDTH / 2,
|
|
|
|
y: display::HEIGHT / 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
loop {
|
2021-06-28 10:03:08 +10:00
|
|
|
vblank.wait_for_vblank();
|
2021-03-07 04:58:59 +11:00
|
|
|
|
|
|
|
input.update();
|
|
|
|
pos.x += input.x_tri() as i32;
|
|
|
|
pos.y += input.y_tri() as i32;
|
|
|
|
|
|
|
|
pos.x = pos.x.clamp(0, display::WIDTH - 1);
|
|
|
|
pos.y = pos.y.clamp(0, display::HEIGHT - 1);
|
|
|
|
bitmap.draw_point(pos.x, pos.y, 0x001F);
|
|
|
|
}
|
|
|
|
}
|