From bedc46f901f2fa399414665c27912585765f4cb3 Mon Sep 17 00:00:00 2001 From: Avii Date: Fri, 12 Jul 2024 14:49:15 +0200 Subject: [PATCH] fix camera --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5bdcee6..e3b89da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2637,7 +2637,7 @@ dependencies = [ [[package]] name = "minesweeper" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bevy", "bevy_ecs_tilemap", diff --git a/Cargo.toml b/Cargo.toml index 11d7ef6..99b94f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minesweeper" -version = "0.1.0" +version = "0.1.1" edition = "2021" # Enable max optimizations for dependencies, but not for our code: diff --git a/src/main.rs b/src/main.rs index fca529e..69b8ad7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,9 @@ fn setup_camera(mut commands: Commands) { z: 1.0, }; + let offset_x = (translation.x / 16.0) as isize; + let offset_y = (translation.y / 16.0) as isize; + commands.spawn(( Camera2dBundle { projection: OrthographicProjection { @@ -53,14 +56,14 @@ fn setup_camera(mut commands: Commands) { ..Default::default() }, transform: Transform { - translation, + translation: (translation % 16.0), ..default() }, ..default() }, TileOffset { - x: 0, - y: 0, + x: offset_x, + y: offset_y, translation, }, ));