rename variable
Some checks failed
Rust Checks / checks (push) Waiting to run
Rust Checks / checks (pull_request) Has been cancelled

This commit is contained in:
CoCo_Sol 2024-03-05 17:52:17 +01:00
parent 0b7f48127d
commit 29ba228716

View file

@ -18,9 +18,9 @@ impl Plugin for RendererPlugin {
} }
} }
/// The offset between the center of the tiles in the map. /// The gap between the center of the tiles in the map.
#[derive(Resource)] #[derive(Resource)]
struct TilesOffset(Vec2); struct TilesGap(Vec2);
/// The size of the tiles in the map. /// The size of the tiles in the map.
#[derive(Resource, Clone, Copy)] #[derive(Resource, Clone, Copy)]
@ -54,7 +54,7 @@ impl Tile {
/// Init resources related to the rendering of the map. /// Init resources related to the rendering of the map.
fn init_resources_for_rendering(mut commands: Commands) { fn init_resources_for_rendering(mut commands: Commands) {
commands.insert_resource(TilesOffset(Vec2 { x: 70., y: 40. })); commands.insert_resource(TilesGap(Vec2 { x: 70., y: 40. }));
commands.insert_resource(TilesSize(Vec2 { x: 125., y: 100. })) commands.insert_resource(TilesSize(Vec2 { x: 125., y: 100. }))
} }
@ -63,13 +63,13 @@ fn render_map(
query: Query<(Entity, &TilePosition, &Tile), Changed<Tile>>, query: Query<(Entity, &TilePosition, &Tile), Changed<Tile>>,
mut commands: Commands, mut commands: Commands,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
tiles_offset: Res<TilesOffset>, tiles_gap: Res<TilesGap>,
tiles_size: Res<TilesSize>, tiles_size: Res<TilesSize>,
) { ) {
for (entity, position, tile) in query.iter() { for (entity, position, tile) in query.iter() {
let texture = tile.get_texture(&asset_server); let texture = tile.get_texture(&asset_server);
let translation_2d = tiles_offset.0 * position.to_pixel_coordinates(); let translation_2d = tiles_gap.0 * position.to_pixel_coordinates();
let translation = Vec3::new( let translation = Vec3::new(
translation_2d.x, translation_2d.x,
translation_2d.y, translation_2d.y,