Skip to content

Commit

Permalink
Centers level tile positions to origin
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmaita committed Nov 14, 2023
1 parent 9f8e05f commit 8a141a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ pub fn generate_level(mut commands: Commands) {
.unwrap_or(&Color::BLACK)
.to_owned();
let custom_size = Some(TILE_SIZE);
let position = Vec2::new(x as f32, y as f32) * TILE_SIZE;
let position =
Vec2::new(x as f32 - GRID_SIZE.x / 2., y as f32 - GRID_SIZE.y / 2.) * TILE_SIZE;
let translation = position.extend(0.0);
let transform = Transform::from_translation(translation);

Expand Down

0 comments on commit 8a141a3

Please sign in to comment.