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>>,
|
||||
/// Camera scroll (negative draw offset) for rendering
|
||||
pub scroll: IVec2,
|
||||
/// Size (used for rendering)
|
||||
pub size: IVec2,
|
||||
/// Are tiles indices half-tile indices?
|
||||
pub half_tile: bool,
|
||||
/// Is this background being displayed?
|
||||
|
@ -22,6 +24,7 @@ impl Default for Background {
|
|||
scroll: IVec2::ZERO,
|
||||
half_tile: false,
|
||||
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;
|
||||
let mut startx = map.scroll.x / tilesize;
|
||||
let mut starty = map.scroll.y / tilesize;
|
||||
let endx =
|
||||
(BACKGROUND_MAX_SIZE as i32).min(startx + (screen_size.x / TILE_SIZE as i32 + 1) * tcmult);
|
||||
let endy =
|
||||
(BACKGROUND_MAX_SIZE as i32).min(starty + (screen_size.y / TILE_SIZE as i32 + 1) * tcmult);
|
||||
let endx = map
|
||||
.size
|
||||
.x
|
||||
.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);
|
||||
starty = 0.max(starty);
|
||||
for x in startx..endx {
|
||||
|
|
Loading…
Reference in New Issue