Compare commits

..

2 commits

Author SHA1 Message Date
48b5b3f3c7 bump version to 0.3.1 2025-04-05 23:51:56 +02:00
2a0483c156 fix crash when completing level with a wide machine 2025-04-05 23:46:52 +02:00
4 changed files with 22 additions and 10 deletions

View file

@ -3,6 +3,10 @@ Game store page: https://crispypin.itch.io/marble-machinations
## [unreleased] ## [unreleased]
## v0.3.1 - 2025-04-05
### fixed
- broken area calculation causing crash when completing a level with a machine wider than it is tall
## v0.3.0 - 2025-04-04 ## v0.3.0 - 2025-04-04
### added ### added
- score number: bounding area - score number: bounding area

4
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
@ -213,7 +213,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]] [[package]]
name = "marble-machinations" name = "marble-machinations"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"arboard", "arboard",
"raylib", "raylib",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "marble-machinations" name = "marble-machinations"
version = "0.3.0" version = "0.3.1"
edition = "2021" edition = "2021"
default-run = "marble-machinations" default-run = "marble-machinations"

View file

@ -124,9 +124,9 @@ impl Grid {
} }
pub fn used_bounds_area(&self) -> usize { pub fn used_bounds_area(&self) -> usize {
let row_clear = |a, max, f: fn(usize, usize) -> (usize, usize)| { let row_clear = |y| {
for b in 0..max { for x in 0..self.width {
if !self.get_unchecked(f(a, b).into()).is_blank() { if !self.get_unchecked((x, y).into()).is_blank() {
return false; return false;
} }
} }
@ -134,29 +134,37 @@ impl Grid {
}; };
let mut height = self.height; let mut height = self.height;
for y in 0..self.height { for y in 0..self.height {
if row_clear(y, self.width, |y, x| (x, y)) { if row_clear(y) {
height -= 1; height -= 1;
} else { } else {
break; break;
} }
} }
for y in (0..self.height).rev() { for y in (0..self.height).rev() {
if row_clear(y, self.width, |y, x| (x, y)) { if row_clear(y) {
height -= 1; height -= 1;
} else { } else {
break; break;
} }
} }
let col_clear = |x| {
for y in 0..self.height {
if !self.get_unchecked((x, y).into()).is_blank() {
return false;
}
}
true
};
let mut width = self.width; let mut width = self.width;
for x in 0..self.width { for x in 0..self.width {
if row_clear(x, self.height, |x, y| (x, y)) { if col_clear(x) {
width -= 1; width -= 1;
} else { } else {
break; break;
} }
} }
for x in (0..self.width).rev() { for x in (0..self.width).rev() {
if row_clear(x, self.width, |x, y| (x, y)) { if col_clear(x) {
width -= 1; width -= 1;
} else { } else {
break; break;