compute tile offset

This commit is contained in:
Zynh Ludwig 2024-08-20 11:58:31 -07:00
parent 46ebd36a9c
commit e2b5513dd3

View file

@ -72,7 +72,9 @@ fn setup(
const TILES: i32 = 9;
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 CENTER: f32 = TOTAL_WIDTH / 2.;
@ -81,8 +83,8 @@ fn setup(
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;
let tile_x = i as f32 * TILE_SPACE - CENTER + OFFSET;
let tile_y = j as f32 * TILE_SPACE - CENTER + OFFSET;
commands.spawn(MaterialMesh2dBundle {
mesh: circle_mesh.clone(),
material: materials.add(color),