feat!: "Syntax sugar" for pixels per meter measure

- Added meters function for better readability
- Adjusted tilemap_bundle transform
- Added 2nd floor in setup_world system

BREAKING CHANGE: Removed HALVED_PIXELS_PER_METER const
This commit is contained in:
Alexey 2026-03-24 12:13:08 +03:00
commit 0c0dcec4b8
6 changed files with 51 additions and 27 deletions

View file

@ -12,10 +12,10 @@ use bevy::{
};
use bevy_rapier2d::prelude::*;
use crate::{HALVED_PIXELS_PER_METER, PIXELS_PER_METER};
use crate::meters;
const TILEMAP_PATH: &'static str = "sprites/level/tilemap.png";
const TILE_DISPLAY_SIZE: UVec2 = UVec2::splat(PIXELS_PER_METER as u32);
const TILE_DISPLAY_SIZE: UVec2 = UVec2::splat(meters(1.) as u32);
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
#[reflect(Component, Debug, PartialEq, Default, Clone)]
@ -45,12 +45,13 @@ pub fn tilemap_bundle(
),
..default()
},
Transform::from_xyz(0., meters(0.5) * size.y as f32 - meters(3.), 0.),
TilemapChunkTileData(tile_data),
Children::spawn(SpawnIter(colliders.into_iter()
.map(move |(collider, pos)| {(
collider.clone(),
Transform::from_xyz(
pos.x - HALVED_PIXELS_PER_METER * size.x as f32,
pos.x - meters(0.5) * size.x as f32,
pos.y,
0.
),