mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
Add rem_euclid_*_px for pixel calculations
This commit is contained in:
parent
4d3d2acd3b
commit
817e1e305e
|
@ -190,8 +190,8 @@ impl<'a> InfiniteScrolledMap<'a> {
|
||||||
|
|
||||||
let current_scroll = self.map.scroll_pos();
|
let current_scroll = self.map.scroll_pos();
|
||||||
let new_scroll = (
|
let new_scroll = (
|
||||||
size.rem_euclid_width(current_scroll.x as i32 + difference.x) as u16,
|
size.rem_euclid_width_px(current_scroll.x as i32 + difference.x) as u16,
|
||||||
size.rem_euclid_height(current_scroll.y as i32 + difference.y) as u16,
|
size.rem_euclid_height_px(current_scroll.y as i32 + difference.y) as u16,
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,14 @@ impl RegularBackgroundSize {
|
||||||
pub(crate) fn rem_euclid_height(&self, y: i32) -> u32 {
|
pub(crate) fn rem_euclid_height(&self, y: i32) -> u32 {
|
||||||
(y as u32) & (self.height() - 1)
|
(y as u32) & (self.height() - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn rem_euclid_width_px(&self, x: i32) -> u32 {
|
||||||
|
(x as u32) & (self.width() * 8 - 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn rem_euclid_height_px(&self, y: i32) -> u32 {
|
||||||
|
(y as u32) & (self.height() * 8 - 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||||
|
|
Loading…
Reference in a new issue