From 9f21c2b2585c05df2d5fb5f7034f9888eb4c2386 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Tue, 8 Oct 2024 22:04:12 +0200 Subject: [PATCH] merge input and output tiles into one, where output is accomplished by marbles moving into the tile, like a bag --- README.md | 1 - assets/tiles/input_off.png | Bin 196 -> 0 bytes assets/tiles/input_on.png | Bin 196 -> 0 bytes assets/tiles/io_tile_off.png | Bin 0 -> 187 bytes assets/tiles/io_tile_on.png | Bin 0 -> 189 bytes assets/tiles/output_off.png | Bin 188 -> 0 bytes assets/tiles/output_on.png | Bin 188 -> 0 bytes src/editor.rs | 3 +-- src/marble_engine.rs | 14 ++++++-------- src/marble_engine/tile.rs | 12 ++++-------- 10 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 assets/tiles/input_off.png delete mode 100644 assets/tiles/input_on.png create mode 100644 assets/tiles/io_tile_off.png create mode 100644 assets/tiles/io_tile_on.png delete mode 100644 assets/tiles/output_off.png delete mode 100644 assets/tiles/output_on.png diff --git a/README.md b/README.md index 0c6ee94..87e66a6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble story/lore blueprints scroll level list -should the output tile consume marbles like the bag instead of needing power? then input and output could be merged to one tile type make marble movement more consistent (`>o o<` depends on internal marble order) decide on marble data size (u32 or byte?) blueprint rotation diff --git a/assets/tiles/input_off.png b/assets/tiles/input_off.png deleted file mode 100644 index c2606d76186b03372ec920731f1b3ae7c6372621..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|-JULvAsQ2t|7;BJX%snd=)i%3 zAAiK7o#*YC$yaej*UO$E@EFHN#{F44~uoc+nT;l%vcl u=Q<7LRz3XiQ=jFlgOEJ)5q=d*PKE>)t5l5-5+OimF?hQAxvX up?<7lMcd)$`vtBrd)Dv>*iU$(!XW<5=AyV?*GizX7(8A5T-G@yGywn&?m+1P diff --git a/assets/tiles/io_tile_off.png b/assets/tiles/io_tile_off.png new file mode 100644 index 0000000000000000000000000000000000000000..afe0ffd25f29807390c408361be53351c04a6991 GIT binary patch literal 187 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|O`a}}AsQ2t|7;BJX%snd=)i%3 zAAiK7o#*YC$yaej*UO$E@EFHN#{F44?$LOEqtg{kJa1L){Yo`d;=87aVvZrqng)*gHI$Bk_2l6yN;+ kP67NX9}OLBd?!t2@XU6&_)b^c5a=2PPgg&ebxsLQ08HsY&j0`b literal 0 HcmV?d00001 diff --git a/assets/tiles/io_tile_on.png b/assets/tiles/io_tile_on.png new file mode 100644 index 0000000000000000000000000000000000000000..b543a9f0a50d0396baa6fa011b8d83a0998aff97 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|EuJopAsQ2t|7;BJX%snd=)i%3 zAAiK7o#*YC$yaej*UO$E@EFHN#{F44K5?<(O+bp7R07D<6A7sa2@zB38tm#Cj#wJLYs|8!`N!>O jJK@N2hL0wmeoPFUYs~&GoK-vr=o|)5S3j3^P6y$s~&#% msn7D&K}eqY$Ym8vPKGjWtHjNvQ=S2x!{F)a=d#Wzp$P!pLP7Na diff --git a/src/editor.rs b/src/editor.rs index 86787b7..77acf7d 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -577,8 +577,7 @@ impl Editor { tool_button((0, 0), "block", Tool::SetTile(Tile::from_char('#'))); tool_button((0, 1), "bag_off", Tool::SetTile(Tile::from_char('B'))); tool_button((0, 2), "trigger_off", Tool::SetTile(Tile::from_char('*'))); - tool_button((0, 3), "input_off", Tool::SetTile(Tile::from_char('I'))); - tool_button((0, 4), "output_off", Tool::SetTile(Tile::from_char('P'))); + tool_button((0, 3), "io_tile_off", Tool::SetTile(Tile::from_char('I'))); tool_button((0, 5), "flipper_off", Tool::SetTile(Tile::from_char('F'))); tool_button((1, 0), "marble", Tool::SetTile(Tile::from_char('o'))); diff --git a/src/marble_engine.rs b/src/marble_engine.rs index 2d5755c..06e992d 100644 --- a/src/marble_engine.rs +++ b/src/marble_engine.rs @@ -128,7 +128,7 @@ impl Machine { .iter() .map(|&pos| { let marble = self.board.get(pos).unwrap(); - let Tile::Marble { value: _, dir } = marble else { + let Tile::Marble { value, dir } = marble else { panic!("broken marble"); }; let front_pos = dir.step(pos); @@ -139,6 +139,10 @@ impl Machine { if let Tile::Powerable(PTile::Bag, _) = front_tile { return Event::Remove; } + if let Tile::Powerable(PTile::IO, _) = front_tile{ + self.output.push(value as u8); + return Event::Remove; + } let can_move_to = |tile| matches!(tile, Some(Tile::Blank | Tile::Digit(_))); @@ -307,19 +311,13 @@ impl Machine { self.propagate_power(*d, d.step(pos)); } } - PTile::Output => { - let sample = self.board.get_or_blank(front_pos); - if let Tile::Marble { value, dir: _ } = sample { - self.output.push(value as u8); - } - } PTile::Bag => { if let Some(front) = self.board.get_blank_mut(front_pos) { *front = Tile::Marble { value: 0, dir }; self.marbles.push(front_pos); } } - PTile::Input => { + PTile::IO => { if let Some(front) = self.board.get_blank_mut(front_pos) { if self.input_index < self.input.len() { let value = self.input[self.input_index] as MarbleValue; diff --git a/src/marble_engine/tile.rs b/src/marble_engine/tile.rs index 0d793ef..6de8e11 100644 --- a/src/marble_engine/tile.rs +++ b/src/marble_engine/tile.rs @@ -25,8 +25,7 @@ pub enum PTile { Math(MathOp), Bag, Flipper, - Input, - Output, + IO, } #[derive(Debug, Clone, Copy, PartialEq)] @@ -88,8 +87,7 @@ impl Tile { '!' => Tile::Powerable(PTile::Gate(GateType::NotEqual), false), 'L' => Tile::Powerable(PTile::Gate(GateType::LessThan), false), 'G' => Tile::Powerable(PTile::Gate(GateType::GreaterThan), false), - 'P' => Tile::Powerable(PTile::Output, false), - 'I' => Tile::Powerable(PTile::Input, false), + 'I' | 'P' => Tile::Powerable(PTile::IO, false), 'F' => Tile::Powerable(PTile::Flipper, false), 'A' => Tile::Powerable(PTile::Math(MathOp::Add), false), 'S' => Tile::Powerable(PTile::Math(MathOp::Sub), false), @@ -142,8 +140,7 @@ impl Tile { }, PTile::Bag => 'B', PTile::Flipper => 'F', - PTile::Input => 'I', - PTile::Output => 'P', + PTile::IO => 'I', }, } } @@ -176,8 +173,7 @@ impl Tile { PTile::Math(math_op) => math_op.texture_name(), PTile::Bag => "bag", PTile::Flipper => "flipper", - PTile::Input => "input", - PTile::Output => "output", + PTile::IO => "io_tile", }; return format!("{root}_{}", if *state { "on" } else { "off" }); }