diff --git a/README.md b/README.md index c93bcfe..2c68f81 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble - background colour setting - hotkeys for everything - more levels -- scroll output bytes - make direct power (comparator -> machine) work, (needs storing power direction in machine tiles) - cut selections, copy to system clipboard - timestamps in solutions and blueprints diff --git a/levels/01_intro/01_output.json b/levels/01_intro/01_output.json index 8a51782..646a4e9 100644 --- a/levels/01_intro/01_output.json +++ b/levels/01_intro/01_output.json @@ -4,8 +4,12 @@ "name": "Zero", "description": "learn how to output data", "init_board": "\n o \n\n I\n\n", - "stages": [{ - "input": [], - "output": [0] - }] + "stages": [ + { + "input": [], + "output": [ + 0 + ] + } + ] } \ No newline at end of file diff --git a/levels/01_intro/04_copy_input.json b/levels/01_intro/04_copy_input.json index 1281381..028bdb2 100644 --- a/levels/01_intro/04_copy_input.json +++ b/levels/01_intro/04_copy_input.json @@ -6,11 +6,5 @@ "stages": [{ "input": "Hello, world!", "output": "Hello, world!" - },{ - "input": "Meow!", - "output": "Meow!" - },{ - "input": "there really isn't much point to more than 2 stages, but here we are", - "output": "there really isn't much point to more than 2 stages, but here we are" }] } \ No newline at end of file diff --git a/levels/01_intro/05_copy_odd.json b/levels/01_intro/05_copy_odd.json index f57e8c6..26d25d9 100644 --- a/levels/01_intro/05_copy_odd.json +++ b/levels/01_intro/05_copy_odd.json @@ -4,9 +4,6 @@ "name": "Odd Cat", "description": "copy only the odd numbers from the input", "stages": [{ - "input": [1, 2, 3, 4, 5, 6, 7], - "output": [1, 3, 5, 7] - },{ "input": [112, 92, 51, 79, 112, 96, 84, 59, 195, 208, 137, 196, 68, 204, 82, 148, 251, 56, 105, 38, 63, 204, 240, 220, 180, 54, 211, 17, 82, 17, 181, 43], "output": [51, 79, 59, 195, 137, 251, 105, 63, 211, 17, 17, 181, 43] }] diff --git a/levels/02_lists/count_fives.json b/levels/02_lists/count_fives.json index 395177f..8a9549f 100644 --- a/levels/02_lists/count_fives.json +++ b/levels/02_lists/count_fives.json @@ -4,9 +4,6 @@ "name": "Fives", "description": "count how many fives are in the input", "stages": [{ - "input": [6, 5, 5, 3, 5, 0], - "output": [3] - },{ "input": [182, 236, 71, 5, 5, 242, 29, 99, 19, 230, 217, 5, 67, 5, 223, 224, 70, 243, 3, 74, 242, 5, 171, 31, 96, 5, 169, 70, 5, 163, 72, 5, 172, 148, 5, 208, 28, 220, 17, 184, 172, 238, 5, 105, 119, 5, 106, 100, 73, 53, 42, 221, 155, 5, 74, 100, 161, 36, 16, 239, 193, 164, 64, 162, 222, 155, 107, 14, 45, 52, 159, 31, 199, 124, 129, 0], "output": [12] }] diff --git a/levels/02_lists/list_length.json b/levels/02_lists/list_length.json index c254b2b..3a6d8b8 100644 --- a/levels/02_lists/list_length.json +++ b/levels/02_lists/list_length.json @@ -4,9 +4,6 @@ "name": "Length", "description": "count how many numbers are in the input, until the first zero", "stages": [{ - "input": [1, 87, 9, 0], - "output": [3] - },{ "input": [182, 236, 71, 5, 5, 242, 29, 99, 19, 230, 217, 5, 67, 5, 223, 224, 70, 243, 3, 74, 242, 5, 171, 31, 96, 5, 169, 70, 5, 163, 72, 5, 172, 148, 5, 208, 28, 220, 17, 184, 172, 0], "output": [41] }] diff --git a/levels/02_lists/null_separation.json b/levels/02_lists/null_separation.json index e455b0d..402912c 100644 --- a/levels/02_lists/null_separation.json +++ b/levels/02_lists/null_separation.json @@ -6,8 +6,5 @@ "stages": [{ "input": "9834726\u0000Hello, worlg!", "output": "Hello, worlg!" - },{ - "input": "aonmbgoirf\u0000this is just to make sure you don't hardcode the output for a better score", - "output": "this is just to make sure you don't hardcode the output for a better score" }] } \ No newline at end of file diff --git a/levels/02_lists/reverse_input.json b/levels/02_lists/reverse_input.json index 9b6eb1e..91ad03d 100644 --- a/levels/02_lists/reverse_input.json +++ b/levels/02_lists/reverse_input.json @@ -4,9 +4,6 @@ "name": "Reverse", "description": "read input until zero and output the same thing in reverse", "stages": [{ - "input": "woem\u0000", - "output": "meow" - },{ "input": "tnropmi yrev\u0000", "output": "very impornt" }] diff --git a/levels/03_text/ascii_to_lower.json b/levels/03_text/ascii_to_lower.json index 401de96..5c19e65 100644 --- a/levels/03_text/ascii_to_lower.json +++ b/levels/03_text/ascii_to_lower.json @@ -4,9 +4,6 @@ "name": "Lowercase", "description": "Convert text to lowercase", "stages": [{ - "input": "FROM THE MOMENT I UNDERSTOOD THE WEAKNESS OF MY FLESH, IT DISGUSTED ME", - "output": "from the moment i understood the weakness of my flesh, it disgusted me" - },{ "input": "I CraVeD tHE strEnGTH AND CerTAinTy oF STeeL", "output": "i craved the strength and certainty of steel" }] diff --git a/levels/03_text/output_decimal.json b/levels/03_text/output_decimal.json index 6cc2f5d..fcc388e 100644 --- a/levels/03_text/output_decimal.json +++ b/levels/03_text/output_decimal.json @@ -4,9 +4,6 @@ "name": "Numbers", "description": "Convert input numbers to text, separated by spaces (32)\n'0' = 48, '1' = 49, '2' = 50, and so on", "stages": [{ - "input": [8, 7, 1], - "output": "8 7 1" - },{ "input": [85, 114, 32, 103, 97, 121, 58, 51], "output": "85 114 32 103 97 121 58 51" }] diff --git a/levels/03_text/parse_decimal.json b/levels/03_text/parse_decimal.json index fea5a42..ece2bef 100644 --- a/levels/03_text/parse_decimal.json +++ b/levels/03_text/parse_decimal.json @@ -4,9 +4,6 @@ "name": "Numbers 2", "description": "Convert input numbers from text, separated by spaces (32)\n'0' = 48, '1' = 49, '2' = 50, and so on", "stages": [{ - "input": "1 2 3", - "output": [1, 2, 3] - },{ "input": "85 114 32 103 97 121 58 51", "output": [85, 114, 32, 103, 97, 121, 58, 51] }] diff --git a/src/editor.rs b/src/editor.rs index bd6bcbe..b6769c9 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -303,7 +303,7 @@ impl Editor { let stage = &self.level.stages()[i]; if self.popup == EndPopup::None { if stage.output().as_bytes() == self.machine.output() { - if i + 1 < self.level.stages().len() { + if i < self.level.stages().len() { self.stage = Some(i + 1); self.total_steps += self.machine.step_count(); self.reset_machine(); @@ -757,8 +757,15 @@ impl Editor { draw_usize(d, textures, self.machine.step_count(), 420, 4, 9, 2); if self.stage > Some(0) { - let total_steps = self.total_steps + self.machine.step_count(); - draw_usize(d, textures, total_steps, 420, 44, 9, 2); + draw_usize( + d, + textures, + self.total_steps + self.machine.step_count(), + 420, + 44, + 9, + 2, + ); } draw_usize(d, textures, self.step_time as usize, 260, 42, 9, 1); @@ -960,22 +967,11 @@ impl Editor { } } - let y = footer_top as i32 + 5; - if let Some(i) = self.stage { - d.draw_text("stage", 370, y, 20, Color::GREEN); - let shown_stage = if self.sim_state == SimState::Editing { - 0 - } else { - i + 1 - }; - let text = format!("{shown_stage}/{}", self.level.stages().len()); - d.draw_text(&text, 370, y + 20, 20, Color::LIGHTGREEN); - } - - let output_x = 440; + let output_x = 370; let output_cell_width = 43; let output_cells = (d.get_screen_width() - output_x) as usize / output_cell_width as usize; + let y = footer_top as i32 + 5; if simple_button(d, output_x, y + 70, 65, 15) { self.output_as_text = !self.output_as_text } diff --git a/src/level.rs b/src/level.rs index 1d268cf..0a23ed8 100644 --- a/src/level.rs +++ b/src/level.rs @@ -67,6 +67,22 @@ impl Level { pub fn stages(&self) -> &[Stage] { &self.stages } + + // pub fn inputs(&self) -> &[u8] { + // self.inputs.as_bytes() + // } + + // pub fn outputs(&self) -> &[u8] { + // self.outputs.as_bytes() + // } + + // pub fn input_is_text(&self) -> bool { + // matches!(self.inputs, IOData::Text(_)) + // } + + // pub fn output_is_text(&self) -> bool { + // matches!(self.outputs, IOData::Text(_)) + // } } impl Stage {