merge input and output tiles into one, where output is accomplished by marbles moving into the tile, like a bag
This commit is contained in:
parent
ae4e84bb90
commit
9f21c2b258
10 changed files with 11 additions and 19 deletions
|
@ -8,7 +8,6 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble
|
||||||
story/lore
|
story/lore
|
||||||
blueprints
|
blueprints
|
||||||
scroll level list
|
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)
|
make marble movement more consistent (`>o o<` depends on internal marble order)
|
||||||
decide on marble data size (u32 or byte?)
|
decide on marble data size (u32 or byte?)
|
||||||
blueprint rotation
|
blueprint rotation
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 196 B |
Binary file not shown.
Before Width: | Height: | Size: 196 B |
BIN
assets/tiles/io_tile_off.png
Normal file
BIN
assets/tiles/io_tile_off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 187 B |
BIN
assets/tiles/io_tile_on.png
Normal file
BIN
assets/tiles/io_tile_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 B |
Binary file not shown.
Before Width: | Height: | Size: 188 B |
Binary file not shown.
Before Width: | Height: | Size: 188 B |
|
@ -577,8 +577,7 @@ impl Editor {
|
||||||
tool_button((0, 0), "block", Tool::SetTile(Tile::from_char('#')));
|
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, 1), "bag_off", Tool::SetTile(Tile::from_char('B')));
|
||||||
tool_button((0, 2), "trigger_off", Tool::SetTile(Tile::from_char('*')));
|
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, 3), "io_tile_off", Tool::SetTile(Tile::from_char('I')));
|
||||||
tool_button((0, 4), "output_off", Tool::SetTile(Tile::from_char('P')));
|
|
||||||
tool_button((0, 5), "flipper_off", Tool::SetTile(Tile::from_char('F')));
|
tool_button((0, 5), "flipper_off", Tool::SetTile(Tile::from_char('F')));
|
||||||
|
|
||||||
tool_button((1, 0), "marble", Tool::SetTile(Tile::from_char('o')));
|
tool_button((1, 0), "marble", Tool::SetTile(Tile::from_char('o')));
|
||||||
|
|
|
@ -128,7 +128,7 @@ impl Machine {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&pos| {
|
.map(|&pos| {
|
||||||
let marble = self.board.get(pos).unwrap();
|
let marble = self.board.get(pos).unwrap();
|
||||||
let Tile::Marble { value: _, dir } = marble else {
|
let Tile::Marble { value, dir } = marble else {
|
||||||
panic!("broken marble");
|
panic!("broken marble");
|
||||||
};
|
};
|
||||||
let front_pos = dir.step(pos);
|
let front_pos = dir.step(pos);
|
||||||
|
@ -139,6 +139,10 @@ impl Machine {
|
||||||
if let Tile::Powerable(PTile::Bag, _) = front_tile {
|
if let Tile::Powerable(PTile::Bag, _) = front_tile {
|
||||||
return Event::Remove;
|
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(_)));
|
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));
|
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 => {
|
PTile::Bag => {
|
||||||
if let Some(front) = self.board.get_blank_mut(front_pos) {
|
if let Some(front) = self.board.get_blank_mut(front_pos) {
|
||||||
*front = Tile::Marble { value: 0, dir };
|
*front = Tile::Marble { value: 0, dir };
|
||||||
self.marbles.push(front_pos);
|
self.marbles.push(front_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PTile::Input => {
|
PTile::IO => {
|
||||||
if let Some(front) = self.board.get_blank_mut(front_pos) {
|
if let Some(front) = self.board.get_blank_mut(front_pos) {
|
||||||
if self.input_index < self.input.len() {
|
if self.input_index < self.input.len() {
|
||||||
let value = self.input[self.input_index] as MarbleValue;
|
let value = self.input[self.input_index] as MarbleValue;
|
||||||
|
|
|
@ -25,8 +25,7 @@ pub enum PTile {
|
||||||
Math(MathOp),
|
Math(MathOp),
|
||||||
Bag,
|
Bag,
|
||||||
Flipper,
|
Flipper,
|
||||||
Input,
|
IO,
|
||||||
Output,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
@ -88,8 +87,7 @@ impl Tile {
|
||||||
'!' => Tile::Powerable(PTile::Gate(GateType::NotEqual), false),
|
'!' => Tile::Powerable(PTile::Gate(GateType::NotEqual), false),
|
||||||
'L' => Tile::Powerable(PTile::Gate(GateType::LessThan), false),
|
'L' => Tile::Powerable(PTile::Gate(GateType::LessThan), false),
|
||||||
'G' => Tile::Powerable(PTile::Gate(GateType::GreaterThan), false),
|
'G' => Tile::Powerable(PTile::Gate(GateType::GreaterThan), false),
|
||||||
'P' => Tile::Powerable(PTile::Output, false),
|
'I' | 'P' => Tile::Powerable(PTile::IO, false),
|
||||||
'I' => Tile::Powerable(PTile::Input, false),
|
|
||||||
'F' => Tile::Powerable(PTile::Flipper, false),
|
'F' => Tile::Powerable(PTile::Flipper, false),
|
||||||
'A' => Tile::Powerable(PTile::Math(MathOp::Add), false),
|
'A' => Tile::Powerable(PTile::Math(MathOp::Add), false),
|
||||||
'S' => Tile::Powerable(PTile::Math(MathOp::Sub), false),
|
'S' => Tile::Powerable(PTile::Math(MathOp::Sub), false),
|
||||||
|
@ -142,8 +140,7 @@ impl Tile {
|
||||||
},
|
},
|
||||||
PTile::Bag => 'B',
|
PTile::Bag => 'B',
|
||||||
PTile::Flipper => 'F',
|
PTile::Flipper => 'F',
|
||||||
PTile::Input => 'I',
|
PTile::IO => 'I',
|
||||||
PTile::Output => 'P',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,8 +173,7 @@ impl Tile {
|
||||||
PTile::Math(math_op) => math_op.texture_name(),
|
PTile::Math(math_op) => math_op.texture_name(),
|
||||||
PTile::Bag => "bag",
|
PTile::Bag => "bag",
|
||||||
PTile::Flipper => "flipper",
|
PTile::Flipper => "flipper",
|
||||||
PTile::Input => "input",
|
PTile::IO => "io_tile",
|
||||||
PTile::Output => "output",
|
|
||||||
};
|
};
|
||||||
return format!("{root}_{}", if *state { "on" } else { "off" });
|
return format!("{root}_{}", if *state { "on" } else { "off" });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue