some tiles?
This commit is contained in:
parent
1fe15d778b
commit
6b23727864
1 changed files with 21 additions and 8 deletions
21
src/main.rs
21
src/main.rs
|
@ -1,4 +1,5 @@
|
||||||
use bevy::{
|
use bevy::{
|
||||||
|
color::palettes::tailwind,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
|
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
|
||||||
};
|
};
|
||||||
|
@ -67,13 +68,25 @@ fn setup(
|
||||||
) {
|
) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2dBundle::default());
|
||||||
|
|
||||||
let circle_mesh = Mesh2dHandle(meshes.add(Circle { radius: 50. }));
|
const TILES: i32 = 9;
|
||||||
let color = Color::hsl(75., 0.95, 0.7);
|
const TILE_SIZE: f32 = 50.;
|
||||||
|
const TOTAL_WIDTH: f32 = (TILE_SIZE + 10.) * TILES as f32;
|
||||||
|
const TILE_SPACE: f32 = TOTAL_WIDTH / TILES as f32;
|
||||||
|
const CENTER: f32 = TOTAL_WIDTH / 2.;
|
||||||
|
|
||||||
|
let circle_mesh = Mesh2dHandle(meshes.add(Rectangle::new(TILE_SIZE, TILE_SIZE)));
|
||||||
|
let color = Color::from(tailwind::NEUTRAL_700);
|
||||||
|
|
||||||
|
for i in 0..=TILES {
|
||||||
|
for j in 0..=TILES {
|
||||||
|
let tile_x = i as f32 * TILE_SPACE - CENTER;
|
||||||
|
let tile_y = j as f32 * TILE_SPACE - CENTER;
|
||||||
commands.spawn(MaterialMesh2dBundle {
|
commands.spawn(MaterialMesh2dBundle {
|
||||||
mesh: circle_mesh,
|
mesh: circle_mesh.clone(),
|
||||||
material: materials.add(color),
|
material: materials.add(color),
|
||||||
transform: Transform::from_xyz(0., 0., 0.),
|
transform: Transform::from_xyz(tile_x, tile_y, 0.),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue