Small fixes

This commit is contained in:
Gwilym Kuiper 2022-02-07 21:58:19 +00:00
parent 3a795fea8f
commit a365c14917
2 changed files with 7 additions and 5 deletions

View file

@ -653,10 +653,9 @@ impl<T: Number> Rect<T> {
impl<T: FixedWidthUnsignedInteger> Rect<T> {
pub fn iter(self) -> impl Iterator<Item = (T, T)> {
let mut x = self.position.x - T::one();
let mut x = self.position.x;
let mut y = self.position.y;
core::iter::from_fn(move || {
x = x + T::one();
if x >= self.position.x + self.size.x {
x = self.position.x;
y = y + T::one();
@ -665,7 +664,10 @@ impl<T: FixedWidthUnsignedInteger> Rect<T> {
}
}
Some((x, y))
let ret_x = x;
x = x + T::one();
Some((ret_x, y))
})
}
}

View file

@ -516,7 +516,7 @@ impl<'a> InfiniteScrolledMap<'a> {
let direction = difference.x.signum();
// either need to update 20 or 21 tiles depending on whether the y coordinate is a perfect multiple
let y_tiles_to_update: i32 = if new_pos.y % 8 == 0 { 20 } else { 21 };
let y_tiles_to_update = 21;
let line_to_update = if direction < 0 {
// moving to the left, so need to update the left most position
@ -540,7 +540,7 @@ impl<'a> InfiniteScrolledMap<'a> {
let direction = difference.y.signum();
// either need to update 30 or 31 tiles depending on whether the x coordinate is a perfect multiple
let x_tiles_to_update: i32 = if new_pos.x % 8 == 0 { 30 } else { 31 };
let x_tiles_to_update: i32 = 31;
let line_to_update = if direction < 0 {
// moving up so need to update the top