Crates.io | grids |
lib.rs | grids |
version | 0.2.3 |
source | src |
created_at | 2023-03-18 21:55:28.440451 |
updated_at | 2023-09-05 17:38:08.195786 |
description | 2D grid data structure for games. |
homepage | |
repository | https://github.com/darthdeus/grids |
max_upload_size | |
id | 814000 |
size | 12,283 |
grids
CrateThis crate provides a simple and flexible 2D grid data structure mainly intended for grid based games.
If you need a matrix this is not the right crate.
serde
feature.glam
and allows indexing with IVec2/UVec2
for extra convenience.Here's a simple example showcasing the usage of the crate:
let mut grid = Grid::new(3, 2, 0); // A 3x2 grid filled with zeros.
grid[(0, 1)] = 5;
// Accessing using glam::IVec2.
assert_eq!(grid[glam::IVec2::new(1, 0)], 0);
// Accessing using glam::UVec2.
assert_eq!(grid[glam::UVec2::new(0, 1)], 5);
// Converting grid to a Vec.
assert_eq!(
grid.into_iter_values().collect::<Vec<_>>(),
vec![0, 0, 0, 5, 0, 0]
);