Compare commits

...

2 commits

22 changed files with 30 additions and 30 deletions

View file

@ -92,12 +92,12 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble
### intro, basic mechanics
- output a zero (marble, io)
- output multiple numbers in sequence (digits)
- output zeroes forever (looping, trigger, bag output)
- output zeroes forever (looping, button, silo output)
- copy the input (input)
- copy only odd input numbers (comparator, math, flipper)
### 0-terminated list processing
- copy the second list
- calculate list length (math, bag input)
- calculate list length (math, silo input)
- count instances of 5 in a list
- reverse a list (bouncing)
### user-friendly numbers

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

BIN
assets/tiles/button_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

BIN
assets/tiles/button_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 240 B

BIN
assets/tiles/silo_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

BIN
assets/tiles/silo_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 124 B

View file

@ -637,7 +637,7 @@ impl Editor {
draw_usize(d, textures, self.machine.step_count(), 420, 4, 9, 2);
draw_usize(d, textures, self.step_time as usize, 540, 42, 9, 1);
draw_usize(d, textures, self.max_step_time as usize, 540, 58, 9, 1);
draw_usize(d, textures, self.max_step_time as usize, 540, 60, 9, 1);
d.draw_text("input:", 603, 8, 10, Color::WHITE);
if simple_button(d, 600, 20, 35, 15) {
@ -786,8 +786,8 @@ impl Editor {
if !hide_tile_tools {
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, 1), "silo_off", Tool::SetTile(Tile::from_char('B')));
tool_button((0, 2), "button_off", Tool::SetTile(Tile::from_char('*')));
tool_button((0, 3), "io_tile_off", Tool::SetTile(Tile::from_char('I')));
tool_button((0, 4), "flipper_off", Tool::SetTile(Tile::from_char('F')));
tool_button((0, 5), "digit_tool", Tool::Digits(None));

View file

@ -117,7 +117,7 @@ impl Machine {
continue;
}
}
Some(Tile::Trigger(true)) => (),
Some(Tile::Button(true)) => (),
_ => continue,
}
let Some(front_tile) = self.board.get_mut(front_pos) else {
@ -151,7 +151,7 @@ impl Machine {
new_marbles.push((front_pos, value, dir));
}
}
PTile::Bag => {
PTile::Silo => {
if front_tile == &Tile::BLANK {
new_marbles.push((front_pos, 0, dir));
}
@ -173,7 +173,7 @@ impl Machine {
}
}
}
Some(Tile::Trigger(_state)) => (),
Some(Tile::Button(_state)) => (),
Some(Tile::Wire(_, _state)) => (),
_ => unreachable!(),
};
@ -202,7 +202,7 @@ impl Machine {
// so they can figure out which directions they are powered from
for &p in &self.powered {
match self.board.get_mut(p) {
Some(Tile::Trigger(state)) => *state = false,
Some(Tile::Button(state)) => *state = false,
Some(Tile::Wire(_, state)) => *state = false,
_ => (),
}
@ -298,7 +298,7 @@ impl Machine {
let target_pos = match front_tile {
Tile::Arrow(d) => d.step(front_pos),
Tile::Mirror(m) => m.new_dir(dir).step(front_pos),
Tile::Trigger(_) => dir.step(front_pos),
Tile::Button(_) => dir.step(front_pos),
_ => continue,
};
let Some(target_tile) = self.board.get_mut(target_pos) else {
@ -319,7 +319,6 @@ impl Machine {
}
}
// let mut triggers_activated = Vec::new();
let mut removed_marbles = Vec::new();
// move marbles
for (i, pos) in self.marbles[..old_marbles].iter_mut().enumerate() {
@ -357,7 +356,7 @@ impl Machine {
}
} else {
let target_pos;
let mut is_trigger = false;
let mut is_button = false;
let mut new_dir = dir;
match front_tile {
Tile::Arrow(d) => {
@ -368,11 +367,11 @@ impl Machine {
new_dir = m.new_dir(dir);
target_pos = new_dir.step(front_pos);
}
Tile::Trigger(_) => {
is_trigger = true;
Tile::Button(_) => {
is_button = true;
target_pos = dir.step(front_pos);
}
Tile::Powerable(PTile::Bag, _) => {
Tile::Powerable(PTile::Silo, _) => {
removed_marbles.push(i);
continue;
}
@ -388,7 +387,7 @@ impl Machine {
};
if let Tile::Open(space_type, Claim::ClaimedIndirect) = target_tile {
move_to(*space_type, target_pos, new_dir, &mut self.board);
if is_trigger {
if is_button {
self.powered.push(front_pos);
}
}
@ -415,7 +414,7 @@ impl Machine {
unreachable!()
};
match tile {
Tile::Trigger(state) => {
Tile::Button(state) => {
*state = true;
for dir in Direction::ALL {
let target_pos = dir.step(pos);
@ -471,7 +470,7 @@ impl Machine {
continue;
}
}
Some(Tile::Trigger(true)) => (),
Some(Tile::Button(true)) => (),
_ => continue,
}
let Some(front_tile) = self.board.get_mut(front_pos) else {

View file

@ -9,7 +9,7 @@ pub enum Tile {
Marble { value: MarbleValue, dir: Direction },
Mirror(MirrorType),
Arrow(Direction),
Trigger(bool),
Button(bool),
Wire(WireType, bool),
Powerable(PTile, bool),
}
@ -33,7 +33,7 @@ pub enum OpenTile {
pub enum PTile {
Gate(GateType),
Math(MathOp),
Bag,
Silo,
Flipper,
IO,
}
@ -84,7 +84,7 @@ impl Tile {
value: 0,
dir: Direction::Down,
},
'*' => Tile::Trigger(false),
'*' => Tile::Button(false),
'-' => Tile::Wire(WireType::Horizontal, false),
'|' => Tile::Wire(WireType::Vertical, false),
'+' => Tile::Wire(WireType::Cross, false),
@ -105,7 +105,7 @@ impl Tile {
'M' => Tile::Powerable(PTile::Math(MathOp::Mul), false),
'D' => Tile::Powerable(PTile::Math(MathOp::Div), false),
'R' => Tile::Powerable(PTile::Math(MathOp::Rem), false),
'B' => Tile::Powerable(PTile::Bag, false),
'B' => Tile::Powerable(PTile::Silo, false),
d @ '0'..='9' => Tile::Open(OpenTile::Digit(d as u8 - b'0'), Claim::Free),
'#' => Tile::Block,
_ => Tile::Open(OpenTile::Blank, Claim::Free),
@ -128,7 +128,7 @@ impl Tile {
Direction::Left => '<',
Direction::Right => '>',
},
Tile::Trigger(_) => '*',
Tile::Button(_) => '*',
Tile::Wire(wire, _) => match wire {
WireType::Vertical => '|',
WireType::Horizontal => '-',
@ -148,7 +148,7 @@ impl Tile {
MathOp::Div => 'D',
MathOp::Rem => 'R',
},
PTile::Bag => 'B',
PTile::Silo => 'B',
PTile::Flipper => 'F',
PTile::IO => 'I',
},
@ -175,11 +175,11 @@ impl Tile {
Tile::Open(OpenTile::Digit(n), _) => return format!("tile_digit_{n}"),
Tile::Mirror(mirror) => mirror.texture_name(),
Tile::Arrow(dir) => dir.arrow_tile_texture_name(),
Tile::Trigger(state) => {
Tile::Button(state) => {
if *state {
"trigger_on"
"button_on"
} else {
"trigger_off"
"button_off"
}
}
Tile::Wire(wire, state) => {
@ -193,7 +193,7 @@ impl Tile {
let root = match tile {
PTile::Gate(gate) => gate.texture_name(),
PTile::Math(math_op) => math_op.texture_name(),
PTile::Bag => "bag",
PTile::Silo => "silo",
PTile::Flipper => "flipper",
PTile::IO => "io_tile",
};

View file

@ -3,9 +3,10 @@ use raylib::prelude::*;
pub const BG_DARK: Color = gray(32);
pub const BG_MEDIUM: Color = gray(48);
pub const BG_LIGHT: Color = gray(64);
pub const BG_WIDGET: Color = gray(96);
pub const BG_WIDGET: Color = gray(64);
pub const BG_WIDGET_ACTIVE: Color = rgb(80, 120, 180);
pub const FG_MARBLE_VALUE: Color = rgb(255, 80, 40);
pub const FG_TOGGLE_ENABLED: Color = gray(200);
pub const fn widget_bg(highlight: bool) -> Color {
if highlight {

View file

@ -68,7 +68,7 @@ pub fn simple_toggle_button(
y + margin,
width - margin * 2,
height - margin * 2,
BG_DARK,
FG_TOGGLE_ENABLED,
);
}
if hover && d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT) {