2024-10-06 00:24:11 +02:00
|
|
|
use std::fs::read_to_string;
|
2024-10-03 22:59:49 +02:00
|
|
|
|
2024-10-06 00:57:24 +02:00
|
|
|
use editor::Editor;
|
2024-10-06 00:24:11 +02:00
|
|
|
use marble_engine::board::Board;
|
2024-10-03 22:59:49 +02:00
|
|
|
use raylib::prelude::*;
|
|
|
|
|
2024-10-06 00:24:11 +02:00
|
|
|
mod editor;
|
2024-10-03 22:59:49 +02:00
|
|
|
mod marble_engine;
|
2024-10-04 21:20:53 +02:00
|
|
|
mod util;
|
|
|
|
use util::*;
|
|
|
|
|
2024-10-03 22:59:49 +02:00
|
|
|
fn main() {
|
2024-10-04 01:21:52 +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-05 17:46:45 +02:00
|
|
|
rl.set_window_min_size(640, 480);
|
|
|
|
rl.set_mouse_cursor(MouseCursor::MOUSE_CURSOR_CROSSHAIR);
|
2024-10-04 22:10:00 +02:00
|
|
|
rl.set_exit_key(None);
|
2024-10-05 23:16:24 +02:00
|
|
|
rl.set_trace_log(TraceLogLevel::LOG_WARNING);
|
2024-10-03 22:59:49 +02:00
|
|
|
|
2024-10-05 17:53:23 +02:00
|
|
|
let mut textures = Textures::default();
|
|
|
|
textures.load_dir("assets", &mut rl, &thread);
|
|
|
|
textures.load_dir("assets/tiles", &mut rl, &thread);
|
2024-10-05 15:19:27 +02:00
|
|
|
|
2024-10-06 00:57:24 +02:00
|
|
|
let mut game = Editor::new_sandbox();
|
2024-10-05 19:45:25 +02:00
|
|
|
let board = Board::parse(&read_to_string("boards/adder.mbl").unwrap());
|
2024-10-04 22:10:00 +02:00
|
|
|
game.load_board(board);
|
2024-10-04 01:21:52 +02:00
|
|
|
|
2024-10-03 22:59:49 +02:00
|
|
|
while !rl.window_should_close() {
|
2024-10-04 22:10:00 +02:00
|
|
|
game.input(&rl);
|
|
|
|
let mut d = rl.begin_drawing(&thread);
|
|
|
|
d.clear_background(Color::new(64, 64, 64, 255));
|
2024-10-06 00:24:11 +02:00
|
|
|
game.draw(&mut d, &textures);
|
2024-10-05 20:22:18 +02:00
|
|
|
}
|
|
|
|
}
|