fix camera

This commit is contained in:
2024-07-12 14:49:15 +02:00
parent ced7f9be8a
commit bedc46f901
3 changed files with 8 additions and 5 deletions

2
Cargo.lock generated
View File

@@ -2637,7 +2637,7 @@ dependencies = [
[[package]]
name = "minesweeper"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"bevy",
"bevy_ecs_tilemap",

View File

@@ -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:

View File

@@ -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,
},
));