summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-19 08:27:06 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-19 08:27:06 -0700
commitcde55b6020d32797a4c000cec283e1cf535474b0 (patch)
treeb9b1a870813c33617556263a8be6ab24d25dab25
parentafae4ace5ffcefa4590b80ddcf097559c64c7413 (diff)
right click to delete
-rw-r--r--src/main.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 7cd1f37..e7f2084 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -48,6 +48,7 @@ struct Input {
last_mouse_chunk_pos: Option<(i32, i32)>,
last_mouse_local_pos: Option<(u8, u8)>,
is_lmb_pressed: bool,
+ is_rmb_pressed: bool,
trigger_test_1: bool,
trigger_test_2: bool,
@@ -122,7 +123,7 @@ impl App {
}
// --TEST DRAWING--
- if self.input.is_lmb_pressed
+ if (self.input.is_lmb_pressed || self.input.is_rmb_pressed)
&& let Some(lm) = self.input.last_mouse_world_pos
{
// start with the bounding box of the drawing brush circle + some margin
@@ -140,8 +141,13 @@ impl App {
< (self.config.brush_radius as i32).pow(2)
&& r > 0.9
{
- let mut cell = Cell::from_material(self.config.brush_material);
- cell.match_parity(self.sim_seqno);
+ let cell = if self.input.is_lmb_pressed {
+ let mut cell = Cell::from_material(self.config.brush_material);
+ cell.match_parity(self.sim_seqno);
+ cell
+ } else {
+ Cell::void()
+ };
// ensure we simulate on the first tick
if let Some(world) = &mut self.world {
world.set_cell_from_game_position(
@@ -239,6 +245,7 @@ impl Default for App {
trigger_test_1: false,
trigger_test_2: false,
is_lmb_pressed: false,
+ is_rmb_pressed: false,
is_up_pressed: false,
is_left_pressed: false,
is_down_pressed: false,
@@ -383,6 +390,8 @@ impl ApplicationHandler for App {
WindowEvent::MouseInput { state, button, .. } => {
if button == MouseButton::Left {
self.input.is_lmb_pressed = state == ElementState::Pressed
+ } else if button == MouseButton::Right {
+ self.input.is_rmb_pressed = state == ElementState::Pressed
}
}
WindowEvent::Resized(size) => {