pub mod editor; pub mod grid; pub mod map_data; pub mod math; pub mod tool; pub mod transform; use editor::Editor; use raylib::prelude::*; use transform::Transform; fn main() { let (mut rl, thread) = raylib::init().resizable().title("Hello there!").build(); rl.set_target_fps(120); let mut editor = Editor::new(); let mut transform = Transform::new(); let mut last_mouse_pos = rl.get_mouse_position(); while !rl.window_should_close() { let screen_width = rl.get_screen_width(); let screen_height = rl.get_screen_height(); // Move the canvas together with the mouse if rl.is_mouse_button_down(MouseButton::MOUSE_MIDDLE_BUTTON) { transform.move_by_px((rl.get_mouse_position() - last_mouse_pos).into()); } // Handle scrolling of the canvas if rl.get_mouse_wheel_move() > 0 { transform.try_zoom_in(rl.get_mouse_position().into()); } else if rl.get_mouse_wheel_move() < 0 { transform.try_zoom_out(rl.get_mouse_position().into()); } editor.update(&rl, &transform); // Update the last mouse position last_mouse_pos = rl.get_mouse_position(); // Drawing section { let mut d = rl.begin_drawing(&thread); d.clear_background(Color::BLACK); grid::draw_grid(&mut d, screen_width, screen_height, &transform); editor.draw_tools(&mut d, &transform); } } }