fix comment line spacing, add comments to first level
This commit is contained in:
parent
cd51c4b47a
commit
ae42cd10a4
3 changed files with 18 additions and 6 deletions
|
@ -5,7 +5,14 @@
|
||||||
"id": "output",
|
"id": "output",
|
||||||
"name": "Zero",
|
"name": "Zero",
|
||||||
"description": "learn how to output data",
|
"description": "learn how to output data",
|
||||||
"init_board": "\n o \n\n I\n\n",
|
"init_board": {
|
||||||
|
"comments": [
|
||||||
|
{ "text": "Welcome :3", "x": 3, "y": 0 },
|
||||||
|
{ "text": "< This is a marble,\n it will move down when you start the machine", "x": 3, "y": 2 },
|
||||||
|
{ "text": "< This is an input/output silo\n when a marble enters it, it disappears\n and the value it held is added to the level output", "x": 3, "y": 5 }
|
||||||
|
],
|
||||||
|
"grid": "\n\n o \n\n\n I\n\n\n"
|
||||||
|
},
|
||||||
"stages": [{
|
"stages": [{
|
||||||
"input": [],
|
"input": [],
|
||||||
"output": [0]
|
"output": [0]
|
||||||
|
|
13
src/board.rs
13
src/board.rs
|
@ -73,11 +73,16 @@ impl Board {
|
||||||
|
|
||||||
pub fn draw_comments(&self, d: &mut RaylibDrawHandle, offset: Vector2, scale: f32) {
|
pub fn draw_comments(&self, d: &mut RaylibDrawHandle, offset: Vector2, scale: f32) {
|
||||||
let tile_size = (TILE_TEXTURE_SIZE * scale) as i32;
|
let tile_size = (TILE_TEXTURE_SIZE * scale) as i32;
|
||||||
|
let font_size = 10 * (scale as i32).max(1);
|
||||||
|
let line_space = 12 * (scale as i32).max(1);
|
||||||
|
|
||||||
for c in &self.comments {
|
for comment in &self.comments {
|
||||||
let px = c.x * tile_size + offset.x as i32;
|
let x = comment.x * tile_size + offset.x as i32;
|
||||||
let py = c.y * tile_size + offset.y as i32;
|
let y = comment.y * tile_size + offset.y as i32;
|
||||||
d.draw_text(&c.text, px, py, 10 * scale as i32, Color::ORANGE);
|
for (i, line) in comment.text.lines().enumerate() {
|
||||||
|
let y = y + line_space * i as i32;
|
||||||
|
d.draw_text(&line, x, y, font_size, Color::ORANGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl Editor {
|
||||||
machine,
|
machine,
|
||||||
sim_state: SimState::Editing,
|
sim_state: SimState::Editing,
|
||||||
view_offset: Vector2::zero(),
|
view_offset: Vector2::zero(),
|
||||||
zoom: 1.,
|
zoom: 2.,
|
||||||
active_tool: Tool::None,
|
active_tool: Tool::None,
|
||||||
output_as_text,
|
output_as_text,
|
||||||
input_as_text,
|
input_as_text,
|
||||||
|
|
Loading…
Add table
Reference in a new issue