agb/examples/the-hat-chooses-the-wizard/src/level_display.rs

40 lines
883 B
Rust
Raw Normal View History

2022-01-31 22:23:53 +00:00
use agb::display::{
2022-10-11 22:36:14 +01:00
tiled::{RegularMap, TileSet, TileSetting, VRamManager},
2022-01-31 22:23:53 +00:00
HEIGHT, WIDTH,
};
2022-01-01 12:09:21 +00:00
const LEVEL_START: u16 = 12 * 28;
const NUMBERS_START: u16 = 12 * 28 + 3;
const HYPHEN: u16 = 12 * 28 + 11;
pub const BLANK: u16 = 11 * 28;
2022-01-31 22:23:53 +00:00
pub fn write_level(
map: &mut RegularMap,
world: u32,
level: u32,
2022-03-28 21:21:06 +01:00
tileset: &'_ TileSet<'_>,
2022-01-31 22:23:53 +00:00
vram: &mut VRamManager,
) {
for (i, &tile) in [
LEVEL_START,
LEVEL_START + 1,
LEVEL_START + 2,
BLANK,
world as u16 + NUMBERS_START - 1,
HYPHEN,
level as u16 + NUMBERS_START - 1,
]
.iter()
.enumerate()
{
map.set_tile(
vram,
(i as u16, 0).into(),
tileset,
2022-01-31 22:23:53 +00:00
TileSetting::from_raw(tile),
);
}
2022-01-01 12:09:21 +00:00
2022-10-01 16:52:23 +01:00
map.set_scroll_pos((-(WIDTH / 2 - 7 * 8 / 2) as i16, -(HEIGHT / 2 - 4) as i16).into());
2022-01-01 12:09:21 +00:00
}