Fix doc examples

This commit is contained in:
Gwilym Inzani 2023-08-30 16:46:05 +01:00
parent 11fe4d92ac
commit dc04785669
2 changed files with 17 additions and 17 deletions

View file

@ -44,25 +44,23 @@ use crate::{
/// # 0, 1, 2]; /// # 0, 1, 2];
/// pub const WIDTH: i32 = // set it to some width /// pub const WIDTH: i32 = // set it to some width
/// # 12; /// # 12;
/// pub const MAP_TILES: &[u8] = &[ // probably load this from a file
/// # 0];
/// } /// }
/// ///
/// agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
///
/// # fn foo(mut gba: agb::Gba) { /// # fn foo(mut gba: agb::Gba) {
/// let (gfx, mut vram) = gba.display.video.tiled0(); /// let (gfx, mut vram) = gba.display.video.tiled0();
/// ///
/// let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp); /// let tileset = water_tiles::tiles.tiles;
/// ///
/// let mut backdrop = InfiniteScrolledMap::new( /// let mut backdrop = InfiniteScrolledMap::new(
/// gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp), /// gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
/// Box::new(|pos| { /// Box::new(|pos| {
/// ( /// (
/// &tileset, /// &tileset,
/// TileSetting::from_raw( /// water_tiles.tile_settings[*tilemap::BACKGROUND_MAP
/// *tilemap::BACKGROUND_MAP
/// .get((pos.x + tilemap::WIDTH * pos.y) as usize) /// .get((pos.x + tilemap::WIDTH * pos.y) as usize)
/// .unwrap_or(&0), /// .unwrap_or(&0)]
/// ),
/// ) /// )
/// }), /// }),
/// ); /// );
@ -140,21 +138,22 @@ impl<'a> InfiniteScrolledMap<'a> {
/// # pub const MAP_TILES: &[u8] = &[0]; /// # pub const MAP_TILES: &[u8] = &[0];
/// # } /// # }
/// # /// #
/// # agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
/// #
/// # fn foo(mut gba: agb::Gba) { /// # fn foo(mut gba: agb::Gba) {
/// # let (gfx, mut vram) = gba.display.video.tiled0(); /// # let (gfx, mut vram) = gba.display.video.tiled0();
/// # /// #
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp); /// # let tileset = water_tiles.tiles;
/// # /// #
/// # let mut backdrop = InfiniteScrolledMap::new( /// # let mut backdrop = InfiniteScrolledMap::new(
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp), /// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
/// # Box::new(|pos| { /// # Box::new(|pos| {
/// # ( /// # (
/// # &tileset, /// # &tileset,
/// # TileSetting::from_raw( /// # tileset.tile_settings[
/// # *tilemap::BACKGROUND_MAP /// # *tilemap::BACKGROUND_MAP
/// # .get((pos.x + tilemap::WIDTH * pos.y) as usize) /// # .get((pos.x + tilemap::WIDTH * pos.y) as usize)
/// # .unwrap_or(&0), /// # .unwrap_or(&0)]
/// # ),
/// # ) /// # )
/// # }), /// # }),
/// # ); /// # );
@ -215,21 +214,22 @@ impl<'a> InfiniteScrolledMap<'a> {
/// # pub const MAP_TILES: &[u8] = &[0]; /// # pub const MAP_TILES: &[u8] = &[0];
/// # } /// # }
/// # /// #
/// # agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
/// #
/// # fn foo(mut gba: agb::Gba) { /// # fn foo(mut gba: agb::Gba) {
/// # let (gfx, mut vram) = gba.display.video.tiled0(); /// # let (gfx, mut vram) = gba.display.video.tiled0();
/// # /// #
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp); /// # let tileset = water_tiles.tiles;
/// # /// #
/// # let mut backdrop = InfiniteScrolledMap::new( /// # let mut backdrop = InfiniteScrolledMap::new(
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp), /// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
/// # Box::new(|pos| { /// # Box::new(|pos| {
/// # ( /// # (
/// # &tileset, /// # &tileset,
/// # TileSetting::from_raw( /// # tileset.tile_settings[
/// # *tilemap::BACKGROUND_MAP /// # *tilemap::BACKGROUND_MAP
/// # .get((pos.x + tilemap::WIDTH * pos.y) as usize) /// # .get((pos.x + tilemap::WIDTH * pos.y) as usize)
/// # .unwrap_or(&0), /// # .unwrap_or(&0)]
/// # ),
/// # ) /// # )
/// # }), /// # }),
/// # ); /// # );

View file

@ -77,11 +77,11 @@
/// agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png"); /// agb::include_background_gfx!(water_tiles, tiles => "examples/water_tiles.png");
/// ///
/// # fn load_tileset(mut gfx: Tiled0, mut vram: VRamManager) { /// # fn load_tileset(mut gfx: Tiled0, mut vram: VRamManager) {
/// let tileset = TileSet::new(water_tiles::tiles.tiles, TileFormat::FourBpp); /// let tileset = water_tiles::tiles.tiles;
/// ///
/// vram.set_background_palettes(water_tiles::PALETTES); /// vram.set_background_palettes(water_tiles::PALETTES);
/// ///
/// let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32, TileFormat::FourBpp); /// let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32, tileset.format());
/// ///
/// for y in 0..20u16 { /// for y in 0..20u16 {
/// for x in 0..30u16 { /// for x in 0..30u16 {