mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
fix
This commit is contained in:
parent
fd82b259cc
commit
22b3497bb3
BIN
agb/examples/font/pixelated.ttf
Normal file
BIN
agb/examples/font/pixelated.ttf
Normal file
Binary file not shown.
|
@ -17,7 +17,7 @@ use agb_fixnum::Rect;
|
|||
|
||||
use core::fmt::Write;
|
||||
|
||||
const FONT: Font = include_font!("examples/font/yoster.ttf", 12);
|
||||
const FONT: Font = include_font!("examples/font/pixelated.ttf", 8);
|
||||
#[agb::entry]
|
||||
fn entry(gba: agb::Gba) -> ! {
|
||||
main(gba);
|
||||
|
@ -32,12 +32,14 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
let palette = Palette16::new(palette);
|
||||
let palette = PaletteVram::new(&palette).unwrap();
|
||||
|
||||
let config = Configuration::new(Size::S16x16, palette);
|
||||
let config = Configuration::new(Size::S16x8, palette);
|
||||
|
||||
let mut wr = BufferedWordRender::new(&FONT, config);
|
||||
let _ = writeln!(
|
||||
wr,
|
||||
"Hello there!\nI spent this weekend writing this text system! Is it any good?\n\nOh, by the way, you can press A to restart!"
|
||||
"{}",
|
||||
"counts for three shoot dice for damage calculation\nmalfunctions all dice after use"
|
||||
.to_ascii_uppercase()
|
||||
);
|
||||
|
||||
let vblank = agb::interrupt::VBlank::get();
|
||||
|
@ -59,7 +61,10 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
wr.commit(oam);
|
||||
|
||||
let start = timer.value();
|
||||
wr.update(Rect::new((0, 0).into(), (WIDTH, 100).into()), num_letters);
|
||||
wr.update(
|
||||
Rect::new((WIDTH / 8, 0).into(), (80, 100).into()),
|
||||
num_letters,
|
||||
);
|
||||
wr.process();
|
||||
let end = timer.value();
|
||||
|
||||
|
@ -67,13 +72,22 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
frame += 1;
|
||||
|
||||
if frame % 4 == 0 {
|
||||
num_letters += 1;
|
||||
}
|
||||
// if frame % 2 == 0 {
|
||||
num_letters += 1;
|
||||
// }
|
||||
|
||||
if input.is_just_pressed(Button::A) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let start = timer.value();
|
||||
drop(wr);
|
||||
let oam = unmanaged.iter();
|
||||
drop(oam);
|
||||
let end = timer.value();
|
||||
agb::println!(
|
||||
"Drop took {} cycles",
|
||||
256 * (end.wrapping_sub(start) as u32)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ impl WordRenderCache {
|
|||
&& prospective_x > position.position.x + position.size.x
|
||||
{
|
||||
self.state.head_position.x = position.position.x;
|
||||
self.state.head_position.y += 15;
|
||||
self.state.head_position.y += 9;
|
||||
}
|
||||
|
||||
for letter in word.letters.iter().skip(self.state.depth_in_word) {
|
||||
|
@ -175,10 +175,10 @@ impl WordRenderCache {
|
|||
}
|
||||
TextElementReference::WhiteSpace(space) => {
|
||||
match space {
|
||||
WhiteSpace::Space => self.state.head_position.x += 10,
|
||||
WhiteSpace::Space => self.state.head_position.x += 2,
|
||||
WhiteSpace::NewLine => {
|
||||
self.state.head_position.x = position.position.x;
|
||||
self.state.head_position.y += 15;
|
||||
self.state.head_position.y += 14;
|
||||
}
|
||||
}
|
||||
self.state.depth_in_elements += 1;
|
||||
|
@ -244,7 +244,6 @@ impl WorkingLetter {
|
|||
fn reset(&mut self) {
|
||||
self.x_position = 0;
|
||||
self.x_offset = 0;
|
||||
self.dynamic.clear(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,11 +381,10 @@ impl WordRender<'_> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let sprite = self
|
||||
.working
|
||||
.letter
|
||||
.dynamic
|
||||
.to_vram(self.config.palette.clone());
|
||||
let mut new_sprite = DynamicSprite::new(self.config.sprite_size);
|
||||
core::mem::swap(&mut self.working.letter.dynamic, &mut new_sprite);
|
||||
let sprite = new_sprite.to_vram(self.config.palette.clone());
|
||||
|
||||
let group = LetterGroup {
|
||||
sprite,
|
||||
width: self.working.letter.x_offset as u16,
|
||||
|
@ -416,8 +414,7 @@ impl WordRender<'_> {
|
|||
self.working.letter.x_offset += font_letter.xmin as i32;
|
||||
}
|
||||
|
||||
let y_position =
|
||||
self.font.ascent() - font_letter.height as i32 - font_letter.ymin as i32 + 4;
|
||||
let y_position = self.font.ascent() - font_letter.height as i32 - font_letter.ymin as i32;
|
||||
|
||||
for y in 0..font_letter.height as usize {
|
||||
for x in 0..font_letter.width as usize {
|
||||
|
|
Loading…
Reference in a new issue