diff --git a/src/editor.rs b/src/editor.rs index 3adb4fe..0cd67c6 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -72,7 +72,7 @@ impl Editor { pub fn new(solution: Solution, level: Level) -> Self { Self { source_board: Board::parse(&solution.board), - machine: Machine::new_empty(1), + machine: Machine::new_empty(level.inputs().to_owned(), 1), sim_state: SimState::Editing, view_offset: Vector2::zero(), zoom: 1, @@ -369,7 +369,7 @@ impl Editor { let output_start = self.machine.output().len().saturating_sub(8); let output_end = output_start + 8; for (box_index, index) in (output_start..output_end).enumerate() { - let x = 600 + 35 * box_index as i32; + let x = 600 + 43 * box_index as i32; let expected_byte = self.level.outputs().get(index); let real_byte = self.machine.output().get(index); @@ -385,8 +385,8 @@ impl Editor { (Color::DARKGRAY, Color::DIMGRAY) }; - d.draw_rectangle(x, y, 30, 30, top_color); - d.draw_rectangle(x, y + 35, 30, 30, bottom_color); + d.draw_rectangle(x, y, 38, 30, top_color); + d.draw_rectangle(x, y + 35, 38, 30, bottom_color); if let Some(&expected_byte) = expected_byte { let top_text = if self.output_as_text && (expected_byte.is_ascii_graphic() || expected_byte.is_ascii_whitespace()) diff --git a/src/level.rs b/src/level.rs index 749bd3d..fa72dcf 100644 --- a/src/level.rs +++ b/src/level.rs @@ -1,7 +1,5 @@ use serde::Deserialize; -use crate::marble_engine::board::Board; - #[derive(Debug, Clone, Deserialize)] pub struct Level { id: String, diff --git a/src/main.rs b/src/main.rs index dc8f21f..6fab1ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,22 +89,10 @@ impl Game { fn draw(&mut self, d: &mut RaylibDrawHandle) { d.clear_background(Color::new(64, 64, 64, 255)); - // let level_list_width = 240; + let level_list_width = d.get_screen_width() / 4; // woah! Reactive UI! so fancy let screen_height = d.get_screen_height(); d.draw_rectangle(0, 0, level_list_width, screen_height, Color::GRAY); - // let (a, b, c) = d.gui_scroll_panel( - // Rectangle { - // x: 10., - // y: 10., - // width: level_list_width as f32 - 20., - // height: screen_height as f32 - 40., - // }, - // Some(rstr!("text")), - // Rectangle{}, - // scroll, - // view, - // ); let clicked = d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT); let mouse_pos = d.get_mouse_position(); diff --git a/src/marble_engine.rs b/src/marble_engine.rs index 55395d0..cfaa880 100644 --- a/src/marble_engine.rs +++ b/src/marble_engine.rs @@ -17,11 +17,11 @@ pub struct Machine { } impl Machine { - pub fn new_empty(width: usize) -> Self { + pub fn new_empty(input:Vec,width: usize) -> Self { Self { board: Board::new_empty(width, width), marbles: Vec::new(), - input: Vec::new(), + input, input_index: 0, output: Vec::new(), steps: 0,