agb/examples/the-dungeon-puzzlers-lament/src/backgrounds.rs

56 lines
1.5 KiB
Rust
Raw Normal View History

2023-07-20 02:41:17 +10:00
use agb::{
display::tiled::{RegularMap, VRamManager},
2023-07-20 02:41:17 +10:00
include_background_gfx,
};
include_background_gfx!(backgrounds, "1e151b",
ui => deduplicate "maps/ui_tiles.png",
level => deduplicate "maps/level.png",
ending => deduplicate "gfx/ending_page.aseprite",
2023-07-20 02:41:17 +10:00
);
mod tilemaps {
use super::backgrounds;
include!(concat!(env!("OUT_DIR"), "/tilemaps.rs"));
}
pub fn load_palettes(vram_manager: &mut VRamManager) {
vram_manager.set_background_palettes(backgrounds::PALETTES);
}
pub fn load_ui(map: &mut RegularMap, vram_manager: &mut VRamManager) {
let ui_tileset = backgrounds::ui.tiles;
2023-07-20 02:41:17 +10:00
for y in 0..20u16 {
for x in 0..30u16 {
let tile_pos = y * 30 + x;
let tile_setting = tilemaps::UI_BACKGROUND_MAP[tile_pos as usize];
map.set_tile(vram_manager, (x, y), &ui_tileset, tile_setting);
2023-07-20 02:41:17 +10:00
}
}
}
pub fn load_level_background(
map: &mut RegularMap,
vram_manager: &mut VRamManager,
level_number: usize,
) {
let level_map = &tilemaps::LEVELS_MAP[level_number];
let level_tileset = backgrounds::level.tiles;
2023-07-20 02:41:17 +10:00
for y in 0..20u16 {
for x in 0..22u16 {
let tile_pos = y * 22 + x;
let tile_setting = level_map[tile_pos as usize];
map.set_tile(vram_manager, (x, y), &level_tileset, tile_setting);
2023-07-20 02:41:17 +10:00
}
}
}
pub fn load_ending_page(map: &mut RegularMap, vram_manager: &mut VRamManager) {
map.fill_with(vram_manager, &backgrounds::ending);
2023-07-20 02:41:17 +10:00
}