2022-02-01 09:23:53 +11:00
|
|
|
use agb::display::{
|
2022-03-29 07:21:06 +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
|
|
|
|
|
|
|
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-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,
|
|
|
|
) {
|
|
|
|
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(),
|
2022-04-25 02:07:43 +10:00
|
|
|
tileset,
|
2022-02-01 09:23:53 +11:00
|
|
|
TileSetting::from_raw(tile),
|
|
|
|
);
|
|
|
|
}
|
2022-01-01 23:09:21 +11:00
|
|
|
|
2022-04-25 02:07:43 +10:00
|
|
|
map.set_scroll_pos((-(WIDTH / 2 - 7 * 8 / 2) as u16, -(HEIGHT / 2 - 4) as u16).into());
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|