36 lines
944 B
Rust
36 lines
944 B
Rust
|
use std::fs::read_to_string;
|
||
|
|
||
|
use marble_engine::parse;
|
||
|
use raylib::prelude::*;
|
||
|
|
||
|
mod marble_engine;
|
||
|
|
||
|
fn main() {
|
||
|
let (mut rl, thread) = raylib::init().resizable().title("Hello, World").build();
|
||
|
rl.set_target_fps(60);
|
||
|
|
||
|
let board = parse(&read_to_string("boards/flow.mbl").unwrap());
|
||
|
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_text("Hello, world!", 12, 12, 20, Color::WHITE);
|
||
|
|
||
|
d.draw_fps(2, 2);
|
||
|
}
|
||
|
}
|