compute tile offset
This commit is contained in:
parent
46ebd36a9c
commit
e2b5513dd3
1 changed files with 5 additions and 3 deletions
|
@ -72,7 +72,9 @@ fn setup(
|
||||||
|
|
||||||
const TILES: i32 = 9;
|
const TILES: i32 = 9;
|
||||||
const TILE_SIZE: f32 = 50.;
|
const TILE_SIZE: f32 = 50.;
|
||||||
const TOTAL_WIDTH: f32 = (TILE_SIZE + 10.) * TILES as f32;
|
const GAP_SIZE: f32 = 10.;
|
||||||
|
const OFFSET: f32 = (TILE_SIZE + GAP_SIZE) / 2.;
|
||||||
|
const TOTAL_WIDTH: f32 = (TILE_SIZE + GAP_SIZE) * TILES as f32;
|
||||||
const TILE_SPACE: f32 = TOTAL_WIDTH / TILES as f32;
|
const TILE_SPACE: f32 = TOTAL_WIDTH / TILES as f32;
|
||||||
const CENTER: f32 = TOTAL_WIDTH / 2.;
|
const CENTER: f32 = TOTAL_WIDTH / 2.;
|
||||||
|
|
||||||
|
@ -81,8 +83,8 @@ fn setup(
|
||||||
|
|
||||||
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;
|
let tile_x = i as f32 * TILE_SPACE - CENTER + OFFSET;
|
||||||
let tile_y = j as f32 * TILE_SPACE - CENTER;
|
let tile_y = j as f32 * TILE_SPACE - CENTER + OFFSET;
|
||||||
commands.spawn(MaterialMesh2dBundle {
|
commands.spawn(MaterialMesh2dBundle {
|
||||||
mesh: circle_mesh.clone(),
|
mesh: circle_mesh.clone(),
|
||||||
material: materials.add(color),
|
material: materials.add(color),
|
||||||
|
|
Loading…
Reference in a new issue