Replies: 2 comments
-
I'm sure you've probably found this example already. If you haven't: I recommend having a look at this provided example: https://github.com/agbrs/agb/blob/master/agb/examples/text_render.rs The The example doesn't clear the #[agb::entry]
fn main(mut gba: agb::Gba) -> ! {
let (gfx, mut vram) = gba.display.video.tiled0();
let vblank = agb::interrupt::VBlank::get();
vram.set_background_palette_raw(&[
0x0000, 0x0ff0, 0x00ff, 0xf00f, 0xf0f0, 0x0f0f, 0xffff, 0x5555, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
]);
let mut bg = gfx.background(
Priority::P0,
RegularBackgroundSize::Background32x32,
TileFormat::FourBpp,
);
bg.set_visible(true);
loop {
let background_tile = vram.new_dynamic_tile().fill_with(6);
// fill the screen with our tile
for y in 0..20u16 {
for x in 0..30u16 {
bg.set_tile(
&mut vram,
(x, y),
&background_tile.tile_set(),
background_tile.tile_setting(),
);
}
}
let mut renderer = FONT.render_text((1u16, 3u16));
let writer = renderer.writer(1, 6, &mut bg, &mut vram);
writeln!(&mut writer, "Hello!!!").unwrap(); // in reality, I change the text every now and then
vblank.wait_for_vblank();
// commit the bg and text onto the vram
bg.commit(&mut vram);
// clear the renderer and the bg
renderer.clear(&mut vram);
bg.clear(&mut vram);
vram.remove_dynamic_tile(background_tile);
}
} |
Beta Was this translation helpful? Give feedback.
-
For debugging, use agb::println. This will output in the mgba console. You do need to set up mgba to actually output this, you can do this through the UI or on the CLI. For the CLI see how the template does it, https://github.com/agbrs/agb/blob/master/template/.cargo/config.toml. For the UI, Tools > Settings > Logging and enable all of GBA Debug and log to console. . Then if you run mgba through the terminal you'll see printlns get printed. For in game text, right now all our APIs are not very good. As you're using the managed sprites stuff (which will probably be removed soon), you'll want to use backgrounds to render text. The example for which is https://github.com/agbrs/agb/blob/master/agb/examples/text_render.rs. If you have any specific problems therein let us know. Aplologies for the late reply, we were working heavily on our jam game, https://setsquare.itch.io/dungeon-tactics-advance, and did not have time to keep on top of the rest of agb. |
Beta Was this translation helpful? Give feedback.
-
To start, I'm very new to both Rust and the agb crate. I've built the "pong" game to the point that both paddles move (one with "ai") and when the ball hits either the left or right side, past the corresponding paddle, it panics because I placed a todo! macro.
Next up I want to add a scoreboard with generic text, and I'm not sure how the whole font/textwriter/textrenderer thing works. This would also be very helpful for basic debugging. Everything is run through mgba-qt, so I don't really get great debugging info in the console. I could be going about that all wrong, though.
Beta Was this translation helpful? Give feedback.
All reactions