mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Update the examples with the new tileset importing
This commit is contained in:
parent
2c556f9ce8
commit
4642a74a0f
|
@ -8,7 +8,7 @@ use alloc::boxed::Box;
|
|||
|
||||
use agb::{
|
||||
display::{
|
||||
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet},
|
||||
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat},
|
||||
Priority,
|
||||
},
|
||||
fixnum::{Num, Vector2D},
|
||||
|
@ -63,20 +63,12 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
|||
|
||||
let (tile, mut vram) = gba.display.video.tiled0();
|
||||
|
||||
let hat = TileSet::new(games::hat.tiles, TileFormat::EightBpp);
|
||||
let purple = TileSet::new(games::purple.tiles, TileFormat::EightBpp);
|
||||
let hyperspace = TileSet::new(games::hyperspace.tiles, TileFormat::EightBpp);
|
||||
let dungeon_puzzler = TileSet::new(games::dungeon_puzzler.tiles, TileFormat::EightBpp);
|
||||
let amplitude = TileSet::new(games::amplitude.tiles, TileFormat::EightBpp);
|
||||
|
||||
let tiles = [hat, purple, hyperspace, dungeon_puzzler, amplitude];
|
||||
|
||||
let tile_settings = &[
|
||||
games::hat.tile_settings,
|
||||
games::purple.tile_settings,
|
||||
games::hyperspace.tile_settings,
|
||||
games::dungeon_puzzler.tile_settings,
|
||||
games::amplitude.tile_settings,
|
||||
let tiles = [
|
||||
games::hat,
|
||||
games::purple,
|
||||
games::hyperspace,
|
||||
games::dungeon_puzzler,
|
||||
games::amplitude,
|
||||
];
|
||||
|
||||
vram.set_background_palettes(games::PALETTES);
|
||||
|
@ -93,7 +85,7 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
|||
|
||||
let game = (pos.x).rem_euclid(tiles.len() as i32 * 30) as usize / 30;
|
||||
let tile_id = (y * 30 + x) as usize;
|
||||
(&tiles[game], tile_settings[game][tile_id])
|
||||
(&tiles[game].tiles, tiles[game].tile_settings[tile_id])
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use agb::{
|
||||
display::tiled::{RegularMap, TileFormat, TileSet, TileSetting, TiledMap, VRamManager},
|
||||
display::tiled::{RegularMap, TileSet, TileSetting, TiledMap, VRamManager},
|
||||
include_background_gfx, rng,
|
||||
};
|
||||
|
||||
|
@ -23,10 +23,7 @@ pub(crate) fn load_help_text(
|
|||
help_text_line: u16,
|
||||
at_tile: (u16, u16),
|
||||
) {
|
||||
let help_tileset = TileSet::new(
|
||||
backgrounds::help.tiles,
|
||||
agb::display::tiled::TileFormat::FourBpp,
|
||||
);
|
||||
let help_tiledata = backgrounds::help;
|
||||
|
||||
for x in 0..16 {
|
||||
let tile_id = help_text_line * 16 + x;
|
||||
|
@ -34,8 +31,8 @@ pub(crate) fn load_help_text(
|
|||
background.set_tile(
|
||||
vram,
|
||||
(x + at_tile.0, at_tile.1).into(),
|
||||
&help_tileset,
|
||||
backgrounds::help.tile_settings[tile_id as usize],
|
||||
&help_tiledata.tiles,
|
||||
help_tiledata.tile_settings[tile_id as usize],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -45,22 +42,10 @@ pub(crate) fn load_description(
|
|||
descriptions_map: &mut RegularMap,
|
||||
vram: &mut VRamManager,
|
||||
) {
|
||||
let (tileset, tile_settings) = if face_id < 10 {
|
||||
(
|
||||
TileSet::new(
|
||||
backgrounds::descriptions1.tiles,
|
||||
agb::display::tiled::TileFormat::FourBpp,
|
||||
),
|
||||
backgrounds::descriptions1.tile_settings,
|
||||
)
|
||||
let description_data = if face_id < 10 {
|
||||
backgrounds::descriptions1
|
||||
} else {
|
||||
(
|
||||
TileSet::new(
|
||||
backgrounds::descriptions2.tiles,
|
||||
agb::display::tiled::TileFormat::FourBpp,
|
||||
),
|
||||
backgrounds::descriptions2.tile_settings,
|
||||
)
|
||||
backgrounds::descriptions2
|
||||
};
|
||||
|
||||
for y in 0..11 {
|
||||
|
@ -69,8 +54,8 @@ pub(crate) fn load_description(
|
|||
descriptions_map.set_tile(
|
||||
vram,
|
||||
(x, y).into(),
|
||||
&tileset,
|
||||
tile_settings[tile_id as usize],
|
||||
&description_data.tiles,
|
||||
description_data.tile_settings[tile_id as usize],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +68,7 @@ fn create_background_map(map: &mut RegularMap, vram: &mut VRamManager, stars_til
|
|||
let blank = rng::gen().rem_euclid(32) < 30;
|
||||
|
||||
let tile_setting = if blank {
|
||||
TileSetting::new((1 << 10) - 1, false, false, 0)
|
||||
TileSetting::BLANK
|
||||
} else {
|
||||
let tile_id = rng::gen().rem_euclid(64) as u16;
|
||||
backgrounds::stars.tile_settings[tile_id as usize]
|
||||
|
@ -99,26 +84,10 @@ fn create_background_map(map: &mut RegularMap, vram: &mut VRamManager, stars_til
|
|||
pub fn show_title_screen(background: &mut RegularMap, vram: &mut VRamManager, sfx: &mut Sfx) {
|
||||
background.set_scroll_pos((0i16, 0).into());
|
||||
vram.set_background_palettes(backgrounds::PALETTES);
|
||||
let tile_set = TileSet::new(
|
||||
backgrounds::title.tiles,
|
||||
agb::display::tiled::TileFormat::FourBpp,
|
||||
);
|
||||
|
||||
background.hide();
|
||||
|
||||
for x in 0..30u16 {
|
||||
for y in 0..20u16 {
|
||||
let tile_id = y * 30 + x;
|
||||
background.set_tile(
|
||||
vram,
|
||||
(x, y).into(),
|
||||
&tile_set,
|
||||
backgrounds::title.tile_settings[tile_id as usize],
|
||||
);
|
||||
}
|
||||
|
||||
sfx.frame();
|
||||
}
|
||||
|
||||
background.fill_with(vram, &backgrounds::title);
|
||||
background.commit(vram);
|
||||
sfx.frame();
|
||||
background.show();
|
||||
|
@ -138,9 +107,8 @@ impl<'a> StarBackground<'a> {
|
|||
background2: &'a mut RegularMap,
|
||||
vram: &'_ mut VRamManager,
|
||||
) -> Self {
|
||||
let stars_tileset = TileSet::new(backgrounds::stars.tiles, TileFormat::FourBpp);
|
||||
create_background_map(background1, vram, &stars_tileset);
|
||||
create_background_map(background2, vram, &stars_tileset);
|
||||
create_background_map(background1, vram, &backgrounds::stars.tiles);
|
||||
create_background_map(background2, vram, &backgrounds::stars.tiles);
|
||||
|
||||
Self {
|
||||
background1,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use agb::{
|
||||
display::tiled::{RegularMap, TileFormat, TileSet, VRamManager},
|
||||
display::tiled::{RegularMap, VRamManager},
|
||||
include_background_gfx,
|
||||
};
|
||||
|
||||
|
@ -19,7 +19,7 @@ pub fn load_palettes(vram_manager: &mut VRamManager) {
|
|||
}
|
||||
|
||||
pub fn load_ui(map: &mut RegularMap, vram_manager: &mut VRamManager) {
|
||||
let ui_tileset = TileSet::new(backgrounds::ui.tiles, TileFormat::FourBpp);
|
||||
let ui_tileset = backgrounds::ui.tiles;
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..30u16 {
|
||||
|
@ -38,7 +38,7 @@ pub fn load_level_background(
|
|||
) {
|
||||
let level_map = &tilemaps::LEVELS_MAP[level_number];
|
||||
|
||||
let level_tileset = TileSet::new(backgrounds::level.tiles, TileFormat::FourBpp);
|
||||
let level_tileset = backgrounds::level.tiles;
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..22u16 {
|
||||
|
@ -51,18 +51,5 @@ pub fn load_level_background(
|
|||
}
|
||||
|
||||
pub fn load_ending_page(map: &mut RegularMap, vram_manager: &mut VRamManager) {
|
||||
let ending_tileset = TileSet::new(backgrounds::ending.tiles, TileFormat::FourBpp);
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..30u16 {
|
||||
let tile_pos = y * 30 + x;
|
||||
|
||||
map.set_tile(
|
||||
vram_manager,
|
||||
(x, y).into(),
|
||||
&ending_tileset,
|
||||
backgrounds::ending.tile_settings[tile_pos as usize],
|
||||
);
|
||||
}
|
||||
}
|
||||
map.fill_with(vram_manager, &backgrounds::ending);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ use agb::{
|
|||
display::{
|
||||
object::{Graphics, OamManaged, Object, Tag, TagMap},
|
||||
tiled::{
|
||||
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TileSet,
|
||||
TiledMap, VRamManager,
|
||||
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TiledMap,
|
||||
VRamManager,
|
||||
},
|
||||
Priority, HEIGHT, WIDTH,
|
||||
},
|
||||
|
@ -793,7 +793,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
TileFormat::FourBpp,
|
||||
);
|
||||
|
||||
let tileset = TileSet::new(tile_sheet::background.tiles, TileFormat::FourBpp);
|
||||
let tileset = tile_sheet::background.tiles;
|
||||
|
||||
for y in 0..32u16 {
|
||||
for x in 0..32u16 {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::sfx::SfxPlayer;
|
||||
use agb::display::tiled::{RegularMap, TileFormat, TileSet, TiledMap, VRamManager};
|
||||
use agb::display::tiled::{RegularMap, TiledMap, VRamManager};
|
||||
|
||||
agb::include_background_gfx!(splash_screens,
|
||||
splash => deduplicate "gfx/splash.png",
|
||||
|
@ -18,19 +18,9 @@ pub fn show_splash_screen(
|
|||
vram: &mut VRamManager,
|
||||
) {
|
||||
map.set_scroll_pos((0i16, 0i16).into());
|
||||
let (tileset, settings) = match which {
|
||||
SplashScreen::Start => (
|
||||
TileSet::new(splash_screens::splash.tiles, TileFormat::FourBpp),
|
||||
splash_screens::splash.tile_settings,
|
||||
),
|
||||
|
||||
SplashScreen::End => (
|
||||
TileSet::new(
|
||||
splash_screens::thanks_for_playing.tiles,
|
||||
TileFormat::FourBpp,
|
||||
),
|
||||
splash_screens::thanks_for_playing.tile_settings,
|
||||
),
|
||||
let tile_data = match which {
|
||||
SplashScreen::Start => splash_screens::splash,
|
||||
SplashScreen::End => splash_screens::thanks_for_playing,
|
||||
};
|
||||
|
||||
let vblank = agb::interrupt::VBlank::get();
|
||||
|
@ -40,19 +30,7 @@ pub fn show_splash_screen(
|
|||
sfx.frame();
|
||||
vblank.wait_for_vblank();
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..30u16 {
|
||||
map.set_tile(
|
||||
vram,
|
||||
(x, y).into(),
|
||||
&tileset,
|
||||
settings[(y * 30 + x) as usize],
|
||||
);
|
||||
}
|
||||
|
||||
sfx.frame();
|
||||
vblank.wait_for_vblank();
|
||||
}
|
||||
map.fill_with(vram, &tile_data);
|
||||
|
||||
map.commit(vram);
|
||||
vram.set_background_palettes(splash_screens::PALETTES);
|
||||
|
|
|
@ -15,7 +15,7 @@ use alloc::{boxed::Box, vec::Vec};
|
|||
use agb::{
|
||||
display::{
|
||||
object::{Graphics, OamManaged, Object, Sprite, Tag, TagMap},
|
||||
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, VRamManager},
|
||||
tiled::{InfiniteScrolledMap, RegularBackgroundSize, TileFormat, VRamManager},
|
||||
Priority, HEIGHT, WIDTH,
|
||||
},
|
||||
fixnum::{num, FixedNum, Rect, Vector2D},
|
||||
|
@ -2191,7 +2191,7 @@ fn game_with_level(gba: &mut agb::Gba) {
|
|||
|
||||
let (background, mut vram) = gba.display.video.tiled0();
|
||||
vram.set_background_palettes(background::PALETTES);
|
||||
let tileset = TileSet::new(background::background.tiles, TileFormat::FourBpp);
|
||||
let tileset = background::background.tiles;
|
||||
let object = gba.display.object.get_managed();
|
||||
|
||||
loop {
|
||||
|
|
Loading…
Reference in a new issue