show step count
BIN
assets/digits/digit_0.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
assets/digits/digit_1.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
assets/digits/digit_2.png
Normal file
After Width: | Height: | Size: 125 B |
BIN
assets/digits/digit_3.png
Normal file
After Width: | Height: | Size: 121 B |
BIN
assets/digits/digit_4.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
assets/digits/digit_5.png
Normal file
After Width: | Height: | Size: 124 B |
BIN
assets/digits/digit_6.png
Normal file
After Width: | Height: | Size: 126 B |
BIN
assets/digits/digit_7.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
assets/digits/digit_8.png
Normal file
After Width: | Height: | Size: 115 B |
BIN
assets/digits/digit_9.png
Normal file
After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 162 B After Width: | Height: | Size: 162 B |
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 163 B |
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 170 B After Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 160 B |
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 163 B |
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 168 B |
|
@ -3,7 +3,7 @@ use std::{mem::transmute, ops::Rem};
|
|||
use raylib::prelude::*;
|
||||
|
||||
use crate::{
|
||||
draw_scaled_texture,
|
||||
draw_scaled_texture, draw_usize,
|
||||
level::Level,
|
||||
marble_engine::{
|
||||
board::{Board, Pos},
|
||||
|
@ -419,6 +419,8 @@ impl Editor {
|
|||
}
|
||||
draw_scaled_texture(d, textures.get("step"), 332, 4, 2.);
|
||||
|
||||
draw_usize(d, textures, self.machine.step_count(), 372, 4, 5, 2);
|
||||
|
||||
let mut input_text = String::from_utf8_lossy(self.machine.input()).to_string();
|
||||
let width = d.get_screen_width();
|
||||
d.draw_text("input:", width - 260, 10, 20, Color::WHITE);
|
||||
|
|
|
@ -46,6 +46,7 @@ impl Game {
|
|||
let mut textures = Textures::default();
|
||||
textures.load_dir("assets", rl, thread);
|
||||
textures.load_dir("assets/tiles", rl, thread);
|
||||
textures.load_dir("assets/digits", rl, thread);
|
||||
|
||||
Self {
|
||||
levels: get_levels(),
|
||||
|
@ -237,7 +238,7 @@ fn get_levels() -> Vec<Level> {
|
|||
levels.push(level);
|
||||
}
|
||||
}
|
||||
levels.sort_by(|a, b| a.sort_order().cmp(&b.sort_order()));
|
||||
levels.sort_by_key(Level::sort_order);
|
||||
levels
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ impl Tile {
|
|||
Tile::Blank => "",
|
||||
Tile::Block => "block",
|
||||
Tile::Marble { value: _, dir: _ } => "marble",
|
||||
Tile::Digit(n) => return format!("digit_{n}"),
|
||||
Tile::Digit(n) => return format!("tile_digit_{n}"),
|
||||
Tile::Mirror(mirror) => mirror.texture_name(),
|
||||
Tile::Arrow(dir) => dir.arrow_texture_name(),
|
||||
Tile::Powerable(tile, state) => {
|
||||
|
|
28
src/util.rs
|
@ -121,7 +121,8 @@ pub fn text_input(
|
|||
Color::WHITE,
|
||||
);
|
||||
let mouse_pos = d.get_mouse_position();
|
||||
if editable && d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT)
|
||||
if editable
|
||||
&& d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT)
|
||||
&& (bounds.check_collision_point_rec(mouse_pos) || *is_selected)
|
||||
{
|
||||
*is_selected = !*is_selected;
|
||||
|
@ -189,6 +190,31 @@ pub fn texture_option_button<T>(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn draw_usize(
|
||||
d: &mut RaylibDrawHandle,
|
||||
textures: &Textures,
|
||||
number: usize,
|
||||
x: i32,
|
||||
y: i32,
|
||||
digits: u8,
|
||||
scale: u8,
|
||||
) {
|
||||
let digits = digits as i32;
|
||||
let scale = scale as i32;
|
||||
for i in 0..digits {
|
||||
d.draw_rectangle(x + 10 * i * scale, y, 8 * scale, 16 * scale, Color::DIMGRAY);
|
||||
}
|
||||
let mut num = number;
|
||||
let mut i = 0;
|
||||
while (num != 0 || i == 0) && i < digits {
|
||||
let texture = textures.get(&format!("digit_{}", num % 10));
|
||||
let x = x + (digits - i - 1) * 10 * scale;
|
||||
draw_scaled_texture(d, texture, x, y, scale as f32);
|
||||
num /= 10;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn userdata_dir() -> PathBuf {
|
||||
PathBuf::from("user")
|
||||
}
|
||||
|
|