From b42ddaa4bf86b782bdbc619f7d66ded41c909465 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Tue, 29 Dec 2020 11:12:11 +0100 Subject: Add snapping module to replace the rigid grid snapping --- src/grid.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/grid.rs') diff --git a/src/grid.rs b/src/grid.rs index d1c4b15..9134a49 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -1,22 +1,10 @@ //! The grid used to divide the map into evenly sized chunks. use crate::colours::DEFAULT_COLOURS; -use crate::math::{self, Vec2}; +use crate::math; use crate::transform::Transform; use raylib::drawing::RaylibDraw; -/// The internal grid length which will be used to snap things to it. -pub const SNAP_SIZE: f64 = 0.5; - -/// Snap a vector to the grid with the factor being the sub-grid accuracy. For instance, 0.5 will -/// snap to half a grid cell, while 2.0 would snap to every second grid cell -pub fn snap_to_grid(mut vec: Vec2, snap_fraction: f64) -> Vec2 { - vec.x = math::round(vec.x, snap_fraction); - vec.y = math::round(vec.y, snap_fraction); - - vec -} - /// Draw an infinite grid that can be moved around on the screen and zoomed in and out of. pub fn draw_grid(rld: &mut D, screen_width: i32, screen_height: i32, transform: &Transform) where -- cgit v1.2.3-70-g09d2