From 7bc4fc1d50d461289d510ae7157865017bb448b6 Mon Sep 17 00:00:00 2001 From: CoCo_Sol <96190446+CoCoSol007@users.noreply.github.com> Date: Sun, 3 Mar 2024 00:37:39 +0100 Subject: [PATCH] update --- crates/border-wars/src/main.rs | 2 +- crates/border-wars/src/map/renderer.rs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/border-wars/src/main.rs b/crates/border-wars/src/main.rs index ba68cde..0187100 100644 --- a/crates/border-wars/src/main.rs +++ b/crates/border-wars/src/main.rs @@ -9,7 +9,7 @@ use border_wars::scenes::ScenesPlugin; fn setup(mut writer: EventWriter) { writer.send(StartMapGeneration { seed: 7128, - radius: 5, + radius: 50, }); } diff --git a/crates/border-wars/src/map/renderer.rs b/crates/border-wars/src/map/renderer.rs index afdcc4a..d0979a7 100644 --- a/crates/border-wars/src/map/renderer.rs +++ b/crates/border-wars/src/map/renderer.rs @@ -4,6 +4,12 @@ use bevy::prelude::*; use crate::map::{Tile, TilePosition}; +#[derive(Resource)] +struct TilesOffset { + x: f32, + y: f32, +} + /// A plugin to render the map. pub struct RendererPlugin; @@ -28,16 +34,25 @@ impl Tile { } } +/// Init resources related to the rendering of the map. +fn init_resources_for_rendering(mut commands: Commands, asset_server: Res) { + commands.insert_resource(TilesOffset { + x: 70., + y: 40., + }) +} + /// Renders the map. fn render_map( query: Query<(Entity, &TilePosition, &Tile), Changed>, mut commands: Commands, asset_server: Res, + mut tiles_offset: Res, ) { for (entity, position, tile) in query.iter() { let pixel_position_ratio = position.to_pixel_coordinates(); - let position_x = 70. * pixel_position_ratio.x; - let position_y = pixel_position_ratio.y * 40.; + let position_x = tiles_offset.x * pixel_position_ratio.x; + let position_y = tiles_offset.y * pixel_position_ratio.y; commands.entity(entity).insert(SpriteBundle { transform: Transform { translation: Vec3 {