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

36 lines
863 B
Rust
Raw Normal View History

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