diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-11 00:46:56 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-11 00:46:56 -0700 |
| commit | 6f67586b8fc6efdb86d0c9a9744c546da97c4dab (patch) | |
| tree | 2c0b328f7427efc5647cde810a361405d914a37c /src/sim/overlay.rs | |
| parent | 167e31655b63aa4d4548532cf0410cea9fd145ca (diff) | |
physics for sand and water
Diffstat (limited to 'src/sim/overlay.rs')
| -rw-r--r-- | src/sim/overlay.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/sim/overlay.rs b/src/sim/overlay.rs index 36a810b..7c5d5a4 100644 --- a/src/sim/overlay.rs +++ b/src/sim/overlay.rs @@ -1,3 +1,5 @@ +use core::range::Range; + use crate::{Config, Input, sim::board::Board}; pub fn create_compute_combined_overlay_offset( @@ -5,7 +7,8 @@ pub fn create_compute_combined_overlay_offset( config: &Config, input: &Input, ) -> impl Fn(i32, i32) -> (u8, u8, u8, u8) { - |x: i32, y: i32| { + // TODO fix this move? + move |x: i32, y: i32| { // could allow negative offsets too let mut offset: (u8, u8, u8, u8) = (0x00, 0x00, 0x00, 0x00); @@ -35,14 +38,12 @@ pub fn create_compute_combined_overlay_offset( } // brush/selection - if (((x - input.last_mouse_pos_on_board.0).pow(2) - + (y - input.last_mouse_pos_on_board.1).pow(2)) as f32) - .sqrt() - < config.brush_size as f32 - { - offset.0 = offset.0.saturating_add(0xAA); - offset.1 = offset.1.saturating_add(0x00); - offset.2 = offset.2.saturating_add(0xAA); + if input.last_mouse_pos_on_board.is_some_and(|p| { + ((x - p.0).pow(2) + (y - p.1).pow(2)) < (config.brush_radius as i32).pow(2) + }) { + offset.0 = offset.0.saturating_add(0x82); + offset.1 = offset.1.saturating_add(0xA1); + offset.2 = offset.2.saturating_add(0xAD); } return offset; |
