add Board marker

main
Zynh Ludwig 2024-08-20 12:23:05 -07:00
parent 00e5bab2a5
commit e57ebb51a8
1 changed files with 24 additions and 11 deletions

View File

@ -63,6 +63,9 @@ fn main() {
.run(); .run();
} }
#[derive(Component)]
struct Board;
fn setup( fn setup(
mut commands: Commands, mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
@ -81,11 +84,20 @@ fn setup(
let tile_mesh = Mesh2dHandle(meshes.add(Rectangle::new(TILE_SIZE, TILE_SIZE))); let tile_mesh = Mesh2dHandle(meshes.add(Rectangle::new(TILE_SIZE, TILE_SIZE)));
let tile_color = Color::from(tailwind::NEUTRAL_700); let tile_color = Color::from(tailwind::NEUTRAL_700);
commands
.spawn((
SpatialBundle {
transform: Transform::from_xyz(0., 0., 0.),
..default()
},
Board,
))
.with_children(|parent| {
for i in 0..TILES { for i in 0..TILES {
for j in 0..TILES { for j in 0..TILES {
let tile_x = i as f32 * TILE_SPACE - CENTER + OFFSET; let tile_x = i as f32 * TILE_SPACE - CENTER + OFFSET;
let tile_y = j as f32 * TILE_SPACE - CENTER + OFFSET; let tile_y = j as f32 * TILE_SPACE - CENTER + OFFSET;
commands.spawn(MaterialMesh2dBundle { parent.spawn(MaterialMesh2dBundle {
mesh: tile_mesh.clone(), mesh: tile_mesh.clone(),
material: materials.add(tile_color), material: materials.add(tile_color),
transform: Transform::from_xyz(tile_x, tile_y, 0.), transform: Transform::from_xyz(tile_x, tile_y, 0.),
@ -93,4 +105,5 @@ fn setup(
}); });
} }
} }
});
} }