2024-10-03 22:59:49 +02:00
|
|
|
use std::fs::read_to_string;
|
|
|
|
|
|
|
|
use marble_engine::parse;
|
|
|
|
use raylib::prelude::*;
|
|
|
|
|
|
|
|
mod marble_engine;
|
|
|
|
|
|
|
|
fn main() {
|
2024-10-03 23:34:16 +02:00
|
|
|
let (mut rl, thread) = raylib::init().resizable().title("good window title").build();
|
2024-10-03 22:59:49 +02:00
|
|
|
rl.set_target_fps(60);
|
|
|
|
|
2024-10-03 23:34:16 +02:00
|
|
|
let board = parse(&read_to_string("boards/adder.mbl").unwrap());
|
2024-10-03 22:59:49 +02:00
|
|
|
let mut pos_offset = Vector2::zero();
|
|
|
|
let mut machine = marble_engine::Machine::new(board, "Vec::new()".bytes().collect());
|
|
|
|
|
|
|
|
while !rl.window_should_close() {
|
|
|
|
if rl.is_key_pressed(KeyboardKey::KEY_SPACE) {
|
|
|
|
machine.step();
|
|
|
|
}
|
|
|
|
if rl.is_mouse_button_down(MouseButton::MOUSE_BUTTON_MIDDLE) {
|
|
|
|
pos_offset += rl.get_mouse_delta()
|
|
|
|
}
|
|
|
|
if rl.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_RIGHT) {
|
|
|
|
pos_offset = Vector2::zero();
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut d = rl.begin_drawing(&thread);
|
|
|
|
d.clear_background(Color::new(64, 64, 64, 255));
|
|
|
|
|
|
|
|
machine.draw(&mut d, pos_offset);
|
|
|
|
|
|
|
|
d.draw_fps(2, 2);
|
|
|
|
}
|
|
|
|
}
|