gsa/examples/basic/main.rs

27 lines
716 B
Rust

use glam::IVec2;
use gsa::{run, Gsa, FACE_DOWN, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_MIDDLE, FACE_LEFT, FACE_RIGHT};
struct Game {}
fn init(gsa: &mut Gsa) -> Game {
gsa.bg[0].fill(0x7101);
//gsa.write_string(IVec2::ONE, "Hello world nyaa~");
gsa.bg[0].rot = 10;
gsa.bg[0].origin = SCREEN_MIDDLE;
gsa.bg[0].scroll = SCREEN_MIDDLE;
Game {}
}
fn update(_game: &mut Game, gsa: &mut Gsa) {
if gsa.button_down(FACE_LEFT) {
gsa.bg[0].rot = gsa.bg[0].rot.wrapping_add(1);
}
if gsa.button_down(FACE_RIGHT) {
gsa.bg[0].rot = gsa.bg[0].rot.wrapping_sub(1);
}
//gsa.bg[0].scroll.x = (gsa.bg[0].scroll.x + 10) % 300;
gsa.bg[0].scroll += gsa.input_dir();
}
run!(init, update);