added size to backgrounds
This commit is contained in:
parent
eebeb478d2
commit
42f8174a51
|
@ -7,6 +7,8 @@ pub struct Background {
|
||||||
pub tiles: Vec<Vec<u16>>,
|
pub tiles: Vec<Vec<u16>>,
|
||||||
/// Camera scroll (negative draw offset) for rendering
|
/// Camera scroll (negative draw offset) for rendering
|
||||||
pub scroll: IVec2,
|
pub scroll: IVec2,
|
||||||
|
/// Size (used for rendering)
|
||||||
|
pub size: IVec2,
|
||||||
/// Are tiles indices half-tile indices?
|
/// Are tiles indices half-tile indices?
|
||||||
pub half_tile: bool,
|
pub half_tile: bool,
|
||||||
/// Is this background being displayed?
|
/// Is this background being displayed?
|
||||||
|
@ -22,6 +24,7 @@ impl Default for Background {
|
||||||
scroll: IVec2::ZERO,
|
scroll: IVec2::ZERO,
|
||||||
half_tile: false,
|
half_tile: false,
|
||||||
active: true,
|
active: true,
|
||||||
|
size: IVec2 { x: 19, y: 11 },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,14 @@ fn render_map(target: &mut [u8], map: &Background, tileset: &[u8], screen_size:
|
||||||
} as i32;
|
} as i32;
|
||||||
let mut startx = map.scroll.x / tilesize;
|
let mut startx = map.scroll.x / tilesize;
|
||||||
let mut starty = map.scroll.y / tilesize;
|
let mut starty = map.scroll.y / tilesize;
|
||||||
let endx =
|
let endx = map
|
||||||
(BACKGROUND_MAX_SIZE as i32).min(startx + (screen_size.x / TILE_SIZE as i32 + 1) * tcmult);
|
.size
|
||||||
let endy =
|
.x
|
||||||
(BACKGROUND_MAX_SIZE as i32).min(starty + (screen_size.y / TILE_SIZE as i32 + 1) * tcmult);
|
.min(startx + (screen_size.x / TILE_SIZE as i32 + 1) * tcmult);
|
||||||
|
let endy = map
|
||||||
|
.size
|
||||||
|
.y
|
||||||
|
.min(starty + (screen_size.y / TILE_SIZE as i32 + 1) * tcmult);
|
||||||
startx = 0.max(startx);
|
startx = 0.max(startx);
|
||||||
starty = 0.max(starty);
|
starty = 0.max(starty);
|
||||||
for x in startx..endx {
|
for x in startx..endx {
|
||||||
|
|
Loading…
Reference in New Issue