From c8ad4818ab11c168dcaa02526ca20bba5204887c Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Fri, 16 Feb 2024 22:40:13 +0100 Subject: [PATCH 01/38] save --- Cargo.lock | 103 ++++++++++++++++++++--- crates/border-wars/Cargo.toml | 1 + crates/border-wars/src/map/generation.rs | 65 ++++++++++++++ crates/border-wars/src/map/hex.rs | 3 +- crates/border-wars/src/map/mod.rs | 16 ++++ 5 files changed, 175 insertions(+), 13 deletions(-) create mode 100644 crates/border-wars/src/map/generation.rs diff --git a/Cargo.lock b/Cargo.lock index bb750c8..33c901a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,7 +93,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.12", "once_cell", "version_check", "zerocopy", @@ -1126,7 +1126,7 @@ checksum = "7915222f4a08ccc782e08d10b751b42e5f9d786e697d0cb3fd09333cb7e8b6ea" dependencies = [ "ahash", "bevy_utils_proc_macros", - "getrandom", + "getrandom 0.2.12", "hashbrown 0.14.3", "instant", "nonmax", @@ -1316,6 +1316,7 @@ version = "0.1.0" dependencies = [ "bevy", "bevy_egui", + "noise", "num", "partial-min-max", "paste", @@ -2108,6 +2109,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -2117,7 +2129,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -2847,7 +2859,7 @@ checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] @@ -2961,6 +2973,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "noise" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba869e17168793186c10ca82c7079a4ffdeac4f1a7d9e755b9491c028180e40" +dependencies = [ + "num-traits", + "rand 0.7.3", + "rand_xorshift", +] + [[package]] name = "nom" version = "7.1.3" @@ -3475,6 +3498,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17fd96390ed3feda12e1dfe2645ed587e0bea749e319333f104a33ff62f77a0b" +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -3482,8 +3518,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -3493,7 +3539,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -3502,7 +3557,25 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.12", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_xorshift" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -3607,7 +3680,7 @@ dependencies = [ "home", "log", "mio", - "rand", + "rand 0.8.5", "tungstenite", "uuid", ] @@ -3639,7 +3712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", - "getrandom", + "getrandom 0.2.12", "libc", "spin", "untrusted", @@ -4342,7 +4415,7 @@ dependencies = [ "http", "httparse", "log", - "rand", + "rand 0.8.5", "rustls", "rustls-native-certs", "rustls-pki-types", @@ -4430,7 +4503,7 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" dependencies = [ - "getrandom", + "getrandom 0.2.12", "serde", ] @@ -4468,6 +4541,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/crates/border-wars/Cargo.toml b/crates/border-wars/Cargo.toml index 70e1543..ccb73ba 100644 --- a/crates/border-wars/Cargo.toml +++ b/crates/border-wars/Cargo.toml @@ -13,6 +13,7 @@ workspace = true [dependencies] bevy = "0.12.1" bevy_egui = "0.24.0" +noise = "0.8.2" num = "0.4.1" partial-min-max = "0.4.0" paste = "1.0.14" diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs new file mode 100644 index 0000000..5863817 --- /dev/null +++ b/crates/border-wars/src/map/generation.rs @@ -0,0 +1,65 @@ +//! All fonctions related to the generation of the map. + +use bevy::prelude::*; +use noise::{NoiseFn, Perlin}; + +use super::hex::*; +use super::Tile; + +/// A plugin to handle the map generation. +pub struct MapGenerationPlugin; + +impl Plugin for MapGenerationPlugin { + fn build(&self, app: &mut App) { + app.add_event::().add_systems( + Update, + generate_map.run_if(in_state(crate::CurrentScene::Game)), + ); + } +} + +/// An event to trigger the generation of the map. +#[derive(Event)] +pub struct MapGenerationEvent { + /// The seed used to generate the map. + pub seed: u32, + + /// The radius of the map. + pub radius: usize, +} + +/// spawns the tiles. +fn generate_map( + mut event: EventReader, + mut commands: Commands, + mut noise: Local>, + mut map_iterator: Local>>, +) { + // Handle map generation events. + for event in event.read() { + *noise = Some(Perlin::new(event.seed)); + *map_iterator = Some(HexPosition(0, 0).spiral(event.radius)); + } + + if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { + if let Some(position) = spiral.next() { + let pixel_position = position.to_pixel_coordinates((0.1, 0.1)); + let type_tile = get_type_tile(pixel_position, perlin); + + commands.spawn((type_tile, position)); + } else { + *noise = None; + *map_iterator = None; + } + } +} + +/// Returns the type of the tile at the given position with the given noise. +fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { + let value = noise.get([position.0 as f64, position.1 as f64]); + match value { + v if v <= -0.4 => Tile::Hill, + v if v >= 0.4 => Tile::Forest, + _ => Tile::Grass, + } +} diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index 5410eff..5ee633c 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -4,6 +4,7 @@ use std::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; +use bevy::prelude::*; use paste::paste; /// Represents a number that can be used in calculations for hexagonal grids. @@ -98,7 +99,7 @@ number_impl! { /// Represents a position in a hexagonal grid. /// We use the axial coordinate system explained in this /// [documentation](https://www.redblobgames.com/grids/hexagons/#coordinates). -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Component)] pub struct HexPosition(pub T, pub T); /// All possible directions in a hexagonal grid. diff --git a/crates/border-wars/src/map/mod.rs b/crates/border-wars/src/map/mod.rs index 515d0c2..00eeeff 100644 --- a/crates/border-wars/src/map/mod.rs +++ b/crates/border-wars/src/map/mod.rs @@ -1,3 +1,19 @@ //! Contains all the logic related to the map. +pub mod generation; pub mod hex; + +use bevy::prelude::*; + +/// The tile of the map. +#[derive(Component)] +pub enum Tile { + /// The hill tile. + Hill, + + /// The grass tile. + Grass, + + /// The forest tile. + Forest, +} -- 2.43.4 From ef693b54d9ce00a734b8737772ca8ede2d33aa89 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Fri, 16 Feb 2024 22:54:16 +0100 Subject: [PATCH 02/38] change doc --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 5863817..0a2b110 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -28,7 +28,7 @@ pub struct MapGenerationEvent { pub radius: usize, } -/// spawns the tiles. +/// spawns the tiles if the event is received. fn generate_map( mut event: EventReader, mut commands: Commands, -- 2.43.4 From 066561ff6c0f6d1e2bd4f8d38a9b618cbd0230b2 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Fri, 16 Feb 2024 22:55:11 +0100 Subject: [PATCH 03/38] chnage disposition --- crates/border-wars/src/map/generation.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 0a2b110..b3408e4 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -44,9 +44,8 @@ fn generate_map( if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { if let Some(position) = spiral.next() { let pixel_position = position.to_pixel_coordinates((0.1, 0.1)); - let type_tile = get_type_tile(pixel_position, perlin); - commands.spawn((type_tile, position)); + commands.spawn((get_type_tile(pixel_position, perlin), position)); } else { *noise = None; *map_iterator = None; -- 2.43.4 From 32f09423cb0fb309c9a9c0ed84caf6d3098d7c6e Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Fri, 16 Feb 2024 23:21:54 +0100 Subject: [PATCH 04/38] change doc --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index b3408e4..0860304 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -28,7 +28,7 @@ pub struct MapGenerationEvent { pub radius: usize, } -/// spawns the tiles if the event is received. +/// Spawns the tiles if the event is received. fn generate_map( mut event: EventReader, mut commands: Commands, -- 2.43.4 From e3c2bc1ac90f586926bfc5d6e12a9866ab4ca579 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sat, 17 Feb 2024 21:10:40 +0100 Subject: [PATCH 05/38] ajout d'un event de fin de map --- crates/border-wars/src/map/generation.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 0860304..dcd92b8 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -28,9 +28,14 @@ pub struct MapGenerationEvent { pub radius: usize, } +/// An event send when the map is generated. +#[derive(Event)] +pub struct EndMapGenerationEvent; + /// Spawns the tiles if the event is received. fn generate_map( mut event: EventReader, + mut end_map_event: EventWriter, mut commands: Commands, mut noise: Local>, mut map_iterator: Local>>, @@ -47,6 +52,7 @@ fn generate_map( commands.spawn((get_type_tile(pixel_position, perlin), position)); } else { + end_map_event.send(EndMapGenerationEvent); *noise = None; *map_iterator = None; } -- 2.43.4 From 1350b04e296e4cf06a09ffbfb50436c0b2bca54e Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sat, 17 Feb 2024 21:42:38 +0100 Subject: [PATCH 06/38] delete the map --- crates/border-wars/src/map/generation.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index dcd92b8..fa6a8a6 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -11,10 +11,13 @@ pub struct MapGenerationPlugin; impl Plugin for MapGenerationPlugin { fn build(&self, app: &mut App) { - app.add_event::().add_systems( - Update, - generate_map.run_if(in_state(crate::CurrentScene::Game)), - ); + app.add_event::() + .add_event::() + .add_systems( + Update, + (generate_map.after(delete_map), delete_map) + .run_if(in_state(crate::CurrentScene::Game)), + ); } } @@ -68,3 +71,15 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { _ => Tile::Grass, } } + +fn delete_map( + mut commands: Commands, + query: Query>, + mut event: EventReader, +) { + for _ in event.read() { + for entity in query.iter() { + commands.entity(entity).despawn_recursive(); + } + } +} -- 2.43.4 From 0fdc351356db62980e9b7e20ec01460411109c19 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sat, 17 Feb 2024 21:43:21 +0100 Subject: [PATCH 07/38] add doc --- crates/border-wars/src/map/generation.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index fa6a8a6..90a9cd5 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -72,6 +72,7 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { } } +/// Despawns the tiles if the event : [EndMapGenerationEvent] is received. fn delete_map( mut commands: Commands, query: Query>, -- 2.43.4 From 744d9b646e56780f04ba8c2a4c939592889f5231 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sun, 18 Feb 2024 11:17:40 +0100 Subject: [PATCH 08/38] update --- crates/border-wars/src/map/generation.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 90a9cd5..cd5334b 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -52,7 +52,6 @@ fn generate_map( if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { if let Some(position) = spiral.next() { let pixel_position = position.to_pixel_coordinates((0.1, 0.1)); - commands.spawn((get_type_tile(pixel_position, perlin), position)); } else { end_map_event.send(EndMapGenerationEvent); @@ -76,7 +75,7 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { fn delete_map( mut commands: Commands, query: Query>, - mut event: EventReader, + mut event: EventReader, ) { for _ in event.read() { for entity in query.iter() { -- 2.43.4 From fcd0bdf9ed98fd184a207808f41e28795c82218d Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sun, 18 Feb 2024 20:59:52 +0100 Subject: [PATCH 09/38] update --- crates/border-wars/src/map/generation.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index cd5334b..0eca720 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -11,8 +11,8 @@ pub struct MapGenerationPlugin; impl Plugin for MapGenerationPlugin { fn build(&self, app: &mut App) { - app.add_event::() - .add_event::() + app.add_event::() + .add_event::() .add_systems( Update, (generate_map.after(delete_map), delete_map) @@ -23,7 +23,7 @@ impl Plugin for MapGenerationPlugin { /// An event to trigger the generation of the map. #[derive(Event)] -pub struct MapGenerationEvent { +pub struct MapGeneration { /// The seed used to generate the map. pub seed: u32, @@ -33,12 +33,12 @@ pub struct MapGenerationEvent { /// An event send when the map is generated. #[derive(Event)] -pub struct EndMapGenerationEvent; +pub struct EndMapGeneration; /// Spawns the tiles if the event is received. fn generate_map( - mut event: EventReader, - mut end_map_event: EventWriter, + mut event: EventReader, + mut end_map_event: EventWriter, mut commands: Commands, mut noise: Local>, mut map_iterator: Local>>, @@ -51,10 +51,10 @@ fn generate_map( if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { if let Some(position) = spiral.next() { - let pixel_position = position.to_pixel_coordinates((0.1, 0.1)); + let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); // Réduire la taille de la tuile commands.spawn((get_type_tile(pixel_position, perlin), position)); } else { - end_map_event.send(EndMapGenerationEvent); + end_map_event.send(EndMapGeneration); *noise = None; *map_iterator = None; } @@ -65,17 +65,18 @@ fn generate_map( fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { let value = noise.get([position.0 as f64, position.1 as f64]); match value { - v if v <= -0.4 => Tile::Hill, - v if v >= 0.4 => Tile::Forest, + v if v <= -0.5 => Tile::Hill, // Réduire le seuil pour les collines + v if v >= 0.5 => Tile::Forest, // Réduire le seuil pour les forêts _ => Tile::Grass, } } + /// Despawns the tiles if the event : [EndMapGenerationEvent] is received. fn delete_map( mut commands: Commands, query: Query>, - mut event: EventReader, + mut event: EventReader, ) { for _ in event.read() { for entity in query.iter() { -- 2.43.4 From d3c89956a1ea0080fae645e5a43644e853f6cab3 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sun, 18 Feb 2024 21:00:42 +0100 Subject: [PATCH 10/38] update --- crates/border-wars/src/map/generation.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 0eca720..9cf9fff 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -65,13 +65,12 @@ fn generate_map( fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { let value = noise.get([position.0 as f64, position.1 as f64]); match value { - v if v <= -0.5 => Tile::Hill, // Réduire le seuil pour les collines + v if v <= -0.5 => Tile::Hill, // Réduire le seuil pour les collines v if v >= 0.5 => Tile::Forest, // Réduire le seuil pour les forêts _ => Tile::Grass, } } - /// Despawns the tiles if the event : [EndMapGenerationEvent] is received. fn delete_map( mut commands: Commands, -- 2.43.4 From 135f1b73472f0ee9a7bb0f75d33974b8626e920a Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sun, 18 Feb 2024 21:02:32 +0100 Subject: [PATCH 11/38] update doc --- crates/border-wars/src/map/generation.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 9cf9fff..34ccf49 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -51,7 +51,7 @@ fn generate_map( if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { if let Some(position) = spiral.next() { - let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); // Réduire la taille de la tuile + let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); commands.spawn((get_type_tile(pixel_position, perlin), position)); } else { end_map_event.send(EndMapGeneration); @@ -65,8 +65,8 @@ fn generate_map( fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { let value = noise.get([position.0 as f64, position.1 as f64]); match value { - v if v <= -0.5 => Tile::Hill, // Réduire le seuil pour les collines - v if v >= 0.5 => Tile::Forest, // Réduire le seuil pour les forêts + v if v <= -0.5 => Tile::Hill, + v if v >= 0.5 => Tile::Forest, _ => Tile::Grass, } } -- 2.43.4 From f5ffcffb131109b462397dcdaefaf88ea901cbd8 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Sun, 18 Feb 2024 22:04:01 +0100 Subject: [PATCH 12/38] update --- crates/border-wars/src/map/generation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 34ccf49..31aabba 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -65,8 +65,8 @@ fn generate_map( fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { let value = noise.get([position.0 as f64, position.1 as f64]); match value { - v if v <= -0.5 => Tile::Hill, - v if v >= 0.5 => Tile::Forest, + v if v <= -0.4 => Tile::Hill, + v if v >= 0.4 => Tile::Forest, _ => Tile::Grass, } } -- 2.43.4 From 73c25c8bd5bc7192c02bf0948529fb64e51be6c8 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Tue, 20 Feb 2024 11:20:41 +0100 Subject: [PATCH 13/38] rename --- crates/border-wars/src/map/generation.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 31aabba..9efd643 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -11,7 +11,7 @@ pub struct MapGenerationPlugin; impl Plugin for MapGenerationPlugin { fn build(&self, app: &mut App) { - app.add_event::() + app.add_event::() .add_event::() .add_systems( Update, @@ -23,7 +23,7 @@ impl Plugin for MapGenerationPlugin { /// An event to trigger the generation of the map. #[derive(Event)] -pub struct MapGeneration { +pub struct StartMapGeneration { /// The seed used to generate the map. pub seed: u32, @@ -37,7 +37,7 @@ pub struct EndMapGeneration; /// Spawns the tiles if the event is received. fn generate_map( - mut event: EventReader, + mut event: EventReader, mut end_map_event: EventWriter, mut commands: Commands, mut noise: Local>, @@ -75,7 +75,7 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { fn delete_map( mut commands: Commands, query: Query>, - mut event: EventReader, + mut event: EventReader, ) { for _ in event.read() { for entity in query.iter() { -- 2.43.4 From 748bde27b4a08a4342a23e0434d5902d00172c35 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Tue, 20 Feb 2024 11:22:18 +0100 Subject: [PATCH 14/38] change base --- crates/border-wars/src/map/generation.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 9efd643..2d320ca 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -28,7 +28,7 @@ pub struct StartMapGeneration { pub seed: u32, /// The radius of the map. - pub radius: usize, + pub radius: u16, } /// An event send when the map is generated. @@ -41,12 +41,12 @@ fn generate_map( mut end_map_event: EventWriter, mut commands: Commands, mut noise: Local>, - mut map_iterator: Local>>, + mut map_iterator: Local>>, ) { // Handle map generation events. for event in event.read() { *noise = Some(Perlin::new(event.seed)); - *map_iterator = Some(HexPosition(0, 0).spiral(event.radius)); + *map_iterator = Some(HexPosition(0, 0).spiral(event.radius as usize)); } if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { -- 2.43.4 From 07ffb9e45c1c6c531369e4fc1e50aabbd701f2f3 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Tue, 20 Feb 2024 11:31:08 +0100 Subject: [PATCH 15/38] change doc --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 2d320ca..63013da 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -71,7 +71,7 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { } } -/// Despawns the tiles if the event : [EndMapGenerationEvent] is received. +/// Despawns the tiles if the event : [MapGenerationEvent] is received. fn delete_map( mut commands: Commands, query: Query>, -- 2.43.4 From acd2de265c100133443618b3cc7fc1782d73fec0 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Tue, 20 Feb 2024 12:16:05 +0100 Subject: [PATCH 16/38] rename --- crates/border-wars/src/map/generation.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 63013da..ab0b2b1 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -52,17 +52,17 @@ fn generate_map( if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { if let Some(position) = spiral.next() { let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); - commands.spawn((get_type_tile(pixel_position, perlin), position)); + commands.spawn((get_type(pixel_position, perlin), position)); } else { end_map_event.send(EndMapGeneration); *noise = None; *map_iterator = None; } - } + } } -/// Returns the type of the tile at the given position with the given noise. -fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { +/// Returns the type of the position with the given noise. +fn get_type(position: (f32, f32), noise: &Perlin) -> Tile { let value = noise.get([position.0 as f64, position.1 as f64]); match value { v if v <= -0.4 => Tile::Hill, -- 2.43.4 From 915d5ba5a45658afb90eadd1cdef040f4085fd24 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 11:15:54 +0100 Subject: [PATCH 17/38] update --- crates/border-wars/src/map/generation.rs | 26 +++++++++++++----------- crates/border-wars/src/map/hex.rs | 5 +++++ crates/border-wars/src/map/mod.rs | 7 ++++++- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index ab0b2b1..bbb0092 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -5,6 +5,7 @@ use noise::{NoiseFn, Perlin}; use super::hex::*; use super::Tile; +use super::TilePosition; /// A plugin to handle the map generation. pub struct MapGenerationPlugin; @@ -41,24 +42,25 @@ fn generate_map( mut end_map_event: EventWriter, mut commands: Commands, mut noise: Local>, - mut map_iterator: Local>>, + mut spiral: Local>>, ) { // Handle map generation events. for event in event.read() { *noise = Some(Perlin::new(event.seed)); - *map_iterator = Some(HexPosition(0, 0).spiral(event.radius as usize)); + *spiral = Some(TilePosition::new(0,0).spiral(event.radius as usize)); } - if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { - if let Some(position) = spiral.next() { - let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); - commands.spawn((get_type(pixel_position, perlin), position)); - } else { - end_map_event.send(EndMapGeneration); - *noise = None; - *map_iterator = None; - } - } + if let (None, None) = (noise.as_ref(), spiral.as_mut()) { + return; + } + if let Some(position) = spiral.as_mut().unwrap().next() { + let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); + commands.spawn((get_type(pixel_position, &noise.unwrap()), position as TilePosition)); + } else { + end_map_event.send(EndMapGeneration); + *noise = None; + *spiral = None; + } } /// Returns the type of the position with the given noise. diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index 5ee633c..3edb991 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -234,6 +234,11 @@ impl Iterator for HexSpiral { } impl HexPosition { + /// Creates a new [HexPosition]. + pub fn new(x: T, y: T) -> Self { + Self(x, y) + } + /// Converts the current [HexPosition] into a pixel coordinate. /// Input: The size of the hexagon in pixels (witdh, height). /// diff --git a/crates/border-wars/src/map/mod.rs b/crates/border-wars/src/map/mod.rs index 00eeeff..5265d18 100644 --- a/crates/border-wars/src/map/mod.rs +++ b/crates/border-wars/src/map/mod.rs @@ -5,8 +5,13 @@ pub mod hex; use bevy::prelude::*; +use self::hex::*; + +/// The position of a tile in a hexagonal map. +pub type TilePosition = HexPosition; + /// The tile of the map. -#[derive(Component)] +#[derive(Component, Debug)] pub enum Tile { /// The hill tile. Hill, -- 2.43.4 From 74d81721c768cc33879550b32545826932db45cf Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 11:35:11 +0100 Subject: [PATCH 18/38] add let else --- crates/border-wars/src/map/generation.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index bbb0092..d466c1b 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -41,25 +41,25 @@ fn generate_map( mut event: EventReader, mut end_map_event: EventWriter, mut commands: Commands, - mut noise: Local>, - mut spiral: Local>>, + mut local_noise: Local>, + mut local_spiral: Local>>, ) { // Handle map generation events. for event in event.read() { - *noise = Some(Perlin::new(event.seed)); - *spiral = Some(TilePosition::new(0,0).spiral(event.radius as usize)); + *local_noise = Some(Perlin::new(event.seed)); + *local_spiral = Some(TilePosition::new(0,0).spiral(event.radius as usize)); } - if let (None, None) = (noise.as_ref(), spiral.as_mut()) { + let (Some(noise), Some(spiral)) = (local_noise.as_ref(), local_spiral.as_mut()) else { return; - } - if let Some(position) = spiral.as_mut().unwrap().next() { + }; + if let Some(position) = spiral.next() { let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); - commands.spawn((get_type(pixel_position, &noise.unwrap()), position as TilePosition)); + commands.spawn((get_type(pixel_position, &noise), position as TilePosition)); } else { end_map_event.send(EndMapGeneration); - *noise = None; - *spiral = None; + *local_noise = None; + *local_spiral = None; } } -- 2.43.4 From 3ebe60d6cd80967b1be17dc7ad349d1ac2bb96f4 Mon Sep 17 00:00:00 2001 From: Corentin Date: Wed, 21 Feb 2024 10:38:51 +0000 Subject: [PATCH 19/38] Update crates/border-wars/src/map/generation.rs --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index d466c1b..ed56c4e 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -73,7 +73,7 @@ fn get_type(position: (f32, f32), noise: &Perlin) -> Tile { } } -/// Despawns the tiles if the event : [MapGenerationEvent] is received. +/// Despawns the tiles if the event : [StartMapGeneration] is received. fn delete_map( mut commands: Commands, query: Query>, -- 2.43.4 From 6f061deb343189bcf7dc3ab70856f20c3b8936ee Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 11:42:22 +0100 Subject: [PATCH 20/38] fmt --- crates/border-wars/src/map/generation.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index d466c1b..160a1c4 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -4,8 +4,7 @@ use bevy::prelude::*; use noise::{NoiseFn, Perlin}; use super::hex::*; -use super::Tile; -use super::TilePosition; +use super::{Tile, TilePosition}; /// A plugin to handle the map generation. pub struct MapGenerationPlugin; @@ -47,7 +46,7 @@ fn generate_map( // Handle map generation events. for event in event.read() { *local_noise = Some(Perlin::new(event.seed)); - *local_spiral = Some(TilePosition::new(0,0).spiral(event.radius as usize)); + *local_spiral = Some(TilePosition::new(0, 0).spiral(event.radius as usize)); } let (Some(noise), Some(spiral)) = (local_noise.as_ref(), local_spiral.as_mut()) else { -- 2.43.4 From 2f0875d60e650c9b7f92f8ce5532ee696fa9ae72 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 11:50:47 +0100 Subject: [PATCH 21/38] fix clippy --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index af611c0..6e03333 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -54,7 +54,7 @@ fn generate_map( }; if let Some(position) = spiral.next() { let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); - commands.spawn((get_type(pixel_position, &noise), position as TilePosition)); + commands.spawn((get_type(pixel_position, noise), position as TilePosition)); } else { end_map_event.send(EndMapGeneration); *local_noise = None; -- 2.43.4 From 83c36c704dbb34509fd2ea00adf0221c6008a4c5 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 11:54:45 +0100 Subject: [PATCH 22/38] fix clippy --- crates/border-wars/src/map/hex.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index 3edb991..1dc4301 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -235,7 +235,7 @@ impl Iterator for HexSpiral { impl HexPosition { /// Creates a new [HexPosition]. - pub fn new(x: T, y: T) -> Self { + pub const fn new(x: T, y: T) -> Self { Self(x, y) } @@ -262,7 +262,7 @@ impl HexPosition { size.0 * 3f32 .sqrt() - .mul_add(T::to_f32(self.0), 3f32.sqrt() / 2.0 * T::to_f32(self.0)), + .mul_add(T::to_f32(self.0), 3f32.sqrt() / 2.0 * T::to_f32(self.1)), size.1 * (3.0 / 2.0 * T::to_f32(self.1)), ) } -- 2.43.4 From 0d9b7c0ce2d5c96f781d0234bbd812106fac5ffe Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 12:01:21 +0100 Subject: [PATCH 23/38] update --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 6e03333..4a948a4 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -1,4 +1,4 @@ -//! All fonctions related to the generation of the map. +//! All functions related to the generation of the map. use bevy::prelude::*; use noise::{NoiseFn, Perlin}; -- 2.43.4 From 3cf5d76d00d8eaf2470ed2f04ac3dc25d5bda72b Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 17:42:20 +0100 Subject: [PATCH 24/38] update --- crates/border-wars/src/map/generation.rs | 27 ++++++++++++++++-------- crates/border-wars/src/map/hex.rs | 18 ++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 4a948a4..4239923 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -35,36 +35,45 @@ pub struct StartMapGeneration { #[derive(Event)] pub struct EndMapGeneration; -/// Spawns the tiles if the event is received. +/// Generate each tiles of the map if the [StartMapGeneration] is received. +/// +/// The map is generated using the [Perlin] noise function and the [HexSpiral]. +/// +/// It's generated one tile at a time, until the spiral is finished. fn generate_map( - mut event: EventReader, - mut end_map_event: EventWriter, + mut start_generation_events: EventReader, + mut end_generation_writer: EventWriter, mut commands: Commands, mut local_noise: Local>, mut local_spiral: Local>>, ) { - // Handle map generation events. - for event in event.read() { + // Handle map generation events and create the spiral and the noise. + for event in start_generation_events.read() { *local_noise = Some(Perlin::new(event.seed)); *local_spiral = Some(TilePosition::new(0, 0).spiral(event.radius as usize)); } + // Check if the map is being generated. let (Some(noise), Some(spiral)) = (local_noise.as_ref(), local_spiral.as_mut()) else { return; }; + + // Spawn a tile until the spiral is finished + // If the map is generated, we send [EndMapGeneration] and set the local + // variables to None. if let Some(position) = spiral.next() { - let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); + let pixel_position = position.to_pixel_coordinates() * 0.2; commands.spawn((get_type(pixel_position, noise), position as TilePosition)); } else { - end_map_event.send(EndMapGeneration); + end_generation_writer.send(EndMapGeneration); *local_noise = None; *local_spiral = None; } } /// Returns the type of the position with the given noise. -fn get_type(position: (f32, f32), noise: &Perlin) -> Tile { - let value = noise.get([position.0 as f64, position.1 as f64]); +fn get_type(position: Vec2, noise: &Perlin) -> Tile { + let value = noise.get([position.x as f64, position.y as f64]); match value { v if v <= -0.4 => Tile::Hill, v if v >= 0.4 => Tile::Forest, diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index 1dc4301..11d2eca 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -240,7 +240,6 @@ impl HexPosition { } /// Converts the current [HexPosition] into a pixel coordinate. - /// Input: The size of the hexagon in pixels (witdh, height). /// /// If you want to learn more about pixel coordinates conversion, /// you can check the @@ -252,18 +251,13 @@ impl HexPosition { /// use border_wars::map::hex::HexPosition; /// /// let position = HexPosition(1, 0); - /// assert_eq!( - /// position.to_pixel_coordinates((1.0, 1.0)), - /// (3f32.sqrt(), 0.0) - /// ); + /// assert_eq!(position.to_pixel_coordinates(), (3f32.sqrt(), 0.0)); /// ``` - pub fn to_pixel_coordinates(&self, size: (f32, f32)) -> (f32, f32) { - ( - size.0 - * 3f32 - .sqrt() - .mul_add(T::to_f32(self.0), 3f32.sqrt() / 2.0 * T::to_f32(self.1)), - size.1 * (3.0 / 2.0 * T::to_f32(self.1)), + pub fn to_pixel_coordinates(&self) -> Vec2 { + Vec2::new( + 3f32.sqrt() + .mul_add(T::to_f32(self.0), 3f32.sqrt() / 2.0 * T::to_f32(self.1)), + 3.0 / 2.0 * T::to_f32(self.1), ) } -- 2.43.4 From d64d0bb25815862d0a418b12f1ee76ea8882b500 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 17:45:08 +0100 Subject: [PATCH 25/38] update --- crates/border-wars/src/map/hex.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index 11d2eca..b31f29c 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -249,9 +249,10 @@ impl HexPosition { /// /// ```no_run /// use border_wars::map::hex::HexPosition; + /// use bevy::math::Vec2; /// /// let position = HexPosition(1, 0); - /// assert_eq!(position.to_pixel_coordinates(), (3f32.sqrt(), 0.0)); + /// assert_eq!(position.to_pixel_coordinates(), Vec2::new(3f32.sqrt(), 0.0)); /// ``` pub fn to_pixel_coordinates(&self) -> Vec2 { Vec2::new( -- 2.43.4 From 4633db96092d5f191a044ee89f2947256ab06f8d Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 17:48:00 +0100 Subject: [PATCH 26/38] update --- crates/border-wars/src/map/hex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index b31f29c..7ffb02c 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -252,7 +252,7 @@ impl HexPosition { /// use bevy::math::Vec2; /// /// let position = HexPosition(1, 0); - /// assert_eq!(position.to_pixel_coordinates(), Vec2::new(3f32.sqrt(), 0.0)); + /// assert_eq!(position.to_pixel_coordinates(), (3f32.sqrt(), 0.0).into()); /// ``` pub fn to_pixel_coordinates(&self) -> Vec2 { Vec2::new( -- 2.43.4 From 4b1f7008fd6bbde61d069793b35ea6c94d719dad Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 17:49:20 +0100 Subject: [PATCH 27/38] fix fmt --- crates/border-wars/src/map/hex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/hex.rs b/crates/border-wars/src/map/hex.rs index 7ffb02c..415bdfc 100644 --- a/crates/border-wars/src/map/hex.rs +++ b/crates/border-wars/src/map/hex.rs @@ -248,8 +248,8 @@ impl HexPosition { /// # Example /// /// ```no_run - /// use border_wars::map::hex::HexPosition; /// use bevy::math::Vec2; + /// use border_wars::map::hex::HexPosition; /// /// let position = HexPosition(1, 0); /// assert_eq!(position.to_pixel_coordinates(), (3f32.sqrt(), 0.0).into()); -- 2.43.4 From 9e9eec3914e525f2f48af6cbc6fb0b1c88664782 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 17:57:43 +0100 Subject: [PATCH 28/38] save --- crates/border-wars/src/map/generation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 4239923..dd263b3 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -85,9 +85,9 @@ fn get_type(position: Vec2, noise: &Perlin) -> Tile { fn delete_map( mut commands: Commands, query: Query>, - mut event: EventReader, + mut start_generation_events: EventReader, ) { - for _ in event.read() { + for _ in start_generation_events.read() { for entity in query.iter() { commands.entity(entity).despawn_recursive(); } -- 2.43.4 From c11a797d38f8655cdf3432c48f576dcef511af50 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:37:47 +0100 Subject: [PATCH 29/38] save --- crates/border-wars/src/map/generation.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index dd263b3..9587d74 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -9,13 +9,15 @@ use super::{Tile, TilePosition}; /// A plugin to handle the map generation. pub struct MapGenerationPlugin; +const MAP_GENERATION_ZOOM: f32 = 0.2; + impl Plugin for MapGenerationPlugin { fn build(&self, app: &mut App) { app.add_event::() .add_event::() .add_systems( Update, - (generate_map.after(delete_map), delete_map) + (delete_map, generate_map.after(delete_map)) .run_if(in_state(crate::CurrentScene::Game)), ); } @@ -62,8 +64,7 @@ fn generate_map( // If the map is generated, we send [EndMapGeneration] and set the local // variables to None. if let Some(position) = spiral.next() { - let pixel_position = position.to_pixel_coordinates() * 0.2; - commands.spawn((get_type(pixel_position, noise), position as TilePosition)); + commands.spawn((get_type_tile(position, noise), position as TilePosition)); } else { end_generation_writer.send(EndMapGeneration); *local_noise = None; @@ -72,8 +73,9 @@ fn generate_map( } /// Returns the type of the position with the given noise. -fn get_type(position: Vec2, noise: &Perlin) -> Tile { - let value = noise.get([position.x as f64, position.y as f64]); +fn get_type_tile(position: HexPosition, noise: &Perlin) -> Tile { + let pixel_position = position.to_pixel_coordinates() * MAP_GENERATION_ZOOM; + let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]); match value { v if v <= -0.4 => Tile::Hill, v if v >= 0.4 => Tile::Forest, @@ -81,7 +83,7 @@ fn get_type(position: Vec2, noise: &Perlin) -> Tile { } } -/// Despawns the tiles if the event : [StartMapGeneration] is received. +/// Despawns the tiles if the event [StartMapGeneration] is received. fn delete_map( mut commands: Commands, query: Query>, -- 2.43.4 From 62eacf2c84fea64fa853f484b88f6ecb6fb6b63b Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:38:36 +0100 Subject: [PATCH 30/38] add doc --- crates/border-wars/src/map/generation.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 9587d74..2de36e5 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -9,6 +9,7 @@ use super::{Tile, TilePosition}; /// A plugin to handle the map generation. pub struct MapGenerationPlugin; +/// The zoom of the map during the generation. const MAP_GENERATION_ZOOM: f32 = 0.2; impl Plugin for MapGenerationPlugin { -- 2.43.4 From f184c938042da5cdad3feef009c749b09da1e8d8 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:40:20 +0100 Subject: [PATCH 31/38] change doc --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 2de36e5..610a895 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -73,7 +73,7 @@ fn generate_map( } } -/// Returns the type of the position with the given noise. +/// Returns the type of the [HexPosition] with the given noise. fn get_type_tile(position: HexPosition, noise: &Perlin) -> Tile { let pixel_position = position.to_pixel_coordinates() * MAP_GENERATION_ZOOM; let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]); -- 2.43.4 From 7f255d081c97a72eca187212634310977ca343d2 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:41:47 +0100 Subject: [PATCH 32/38] update --- crates/border-wars/src/map/generation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 610a895..2dd0824 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -10,7 +10,7 @@ use super::{Tile, TilePosition}; pub struct MapGenerationPlugin; /// The zoom of the map during the generation. -const MAP_GENERATION_ZOOM: f32 = 0.2; +const MAP_GENERATION_ZOOM: f32 = 5.; impl Plugin for MapGenerationPlugin { fn build(&self, app: &mut App) { @@ -75,7 +75,7 @@ fn generate_map( /// Returns the type of the [HexPosition] with the given noise. fn get_type_tile(position: HexPosition, noise: &Perlin) -> Tile { - let pixel_position = position.to_pixel_coordinates() * MAP_GENERATION_ZOOM; + let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_ZOOM; let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]); match value { v if v <= -0.4 => Tile::Hill, -- 2.43.4 From 65e81d493b7468a0daaf0fe4dd49327fbeea8ef5 Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:47:28 +0100 Subject: [PATCH 33/38] change doc --- crates/border-wars/src/map/renderer.rs | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 crates/border-wars/src/map/renderer.rs diff --git a/crates/border-wars/src/map/renderer.rs b/crates/border-wars/src/map/renderer.rs new file mode 100644 index 0000000..ad38cce --- /dev/null +++ b/crates/border-wars/src/map/renderer.rs @@ -0,0 +1,56 @@ +//! All functions related to the rendering of the map. + +use bevy::prelude::*; + +use super::Tile; +use crate::map::TilePosition; + +/// A plugin to render the map. +pub struct RendererPlugin; + +impl Plugin for RendererPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, setup_camera).add_systems( + Update, + render_map.run_if(in_state(crate::CurrentScene::Game)), + ); + } +} + +/// Sets up the camera. +fn setup_camera(mut commands: Commands) { + commands.spawn(Camera2dBundle::default()); +} + +impl Tile { + /// Returns the texture handle of the tile. + pub fn get_texture(&self, asset_server: &AssetServer) -> Handle { + match self { + Tile::Grass => asset_server.load("tiles/grass.png"), + Tile::Forest => asset_server.load("tiles/forest.png"), + Tile::Hill => asset_server.load("tiles/hill.png"), + } + } +} + +/// Renders the map. +fn render_map( + query: Query<(Entity, &TilePosition, &Tile), Changed>, + mut commands: Commands, + asset_server: Res, +) { + for (entity, position, tile) in query.iter() { + let pixel_position_ratio = position.to_pixel_coordinates(); + let pixel_position = (50. * pixel_position_ratio.x, pixel_position_ratio.y * 30.); + + commands.entity(entity).insert(SpriteBundle { + transform: Transform::from_translation(Vec3 { + x: pixel_position.0, + y: pixel_position.1, + z: 0., + }), + texture: tile.get_texture(&*asset_server), + ..default() + }); + } +} -- 2.43.4 From 0caf97d9b8b32ea44df2c306ecf8e1b89eec5aaf Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:49:45 +0100 Subject: [PATCH 34/38] change doc --- crates/border-wars/src/map/generation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 2dd0824..0869672 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -40,7 +40,7 @@ pub struct EndMapGeneration; /// Generate each tiles of the map if the [StartMapGeneration] is received. /// -/// The map is generated using the [Perlin] noise function and the [HexSpiral]. +/// The map is generated using a [Perlin] noise and a [HexSpiral]. /// /// It's generated one tile at a time, until the spiral is finished. fn generate_map( @@ -74,7 +74,7 @@ fn generate_map( } /// Returns the type of the [HexPosition] with the given noise. -fn get_type_tile(position: HexPosition, noise: &Perlin) -> Tile { +fn get_tile_type(position: HexPosition, noise: &Perlin) -> Tile { let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_ZOOM; let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]); match value { -- 2.43.4 From b77061fed2c6c8fe8376ee38c722c79f2a39f38e Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:50:58 +0100 Subject: [PATCH 35/38] save --- crates/border-wars/src/map/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 0869672..0d40357 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -65,7 +65,7 @@ fn generate_map( // If the map is generated, we send [EndMapGeneration] and set the local // variables to None. if let Some(position) = spiral.next() { - commands.spawn((get_type_tile(position, noise), position as TilePosition)); + commands.spawn((get_tile_type(position, noise), position as TilePosition)); } else { end_generation_writer.send(EndMapGeneration); *local_noise = None; -- 2.43.4 From c34fc16753992e0264c496063585680e0759a4b4 Mon Sep 17 00:00:00 2001 From: Corentin Date: Wed, 21 Feb 2024 17:53:04 +0000 Subject: [PATCH 36/38] Delete crates/border-wars/src/map/renderer.rs --- crates/border-wars/src/map/renderer.rs | 56 -------------------------- 1 file changed, 56 deletions(-) delete mode 100644 crates/border-wars/src/map/renderer.rs diff --git a/crates/border-wars/src/map/renderer.rs b/crates/border-wars/src/map/renderer.rs deleted file mode 100644 index ad38cce..0000000 --- a/crates/border-wars/src/map/renderer.rs +++ /dev/null @@ -1,56 +0,0 @@ -//! All functions related to the rendering of the map. - -use bevy::prelude::*; - -use super::Tile; -use crate::map::TilePosition; - -/// A plugin to render the map. -pub struct RendererPlugin; - -impl Plugin for RendererPlugin { - fn build(&self, app: &mut App) { - app.add_systems(Startup, setup_camera).add_systems( - Update, - render_map.run_if(in_state(crate::CurrentScene::Game)), - ); - } -} - -/// Sets up the camera. -fn setup_camera(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); -} - -impl Tile { - /// Returns the texture handle of the tile. - pub fn get_texture(&self, asset_server: &AssetServer) -> Handle { - match self { - Tile::Grass => asset_server.load("tiles/grass.png"), - Tile::Forest => asset_server.load("tiles/forest.png"), - Tile::Hill => asset_server.load("tiles/hill.png"), - } - } -} - -/// Renders the map. -fn render_map( - query: Query<(Entity, &TilePosition, &Tile), Changed>, - mut commands: Commands, - asset_server: Res, -) { - for (entity, position, tile) in query.iter() { - let pixel_position_ratio = position.to_pixel_coordinates(); - let pixel_position = (50. * pixel_position_ratio.x, pixel_position_ratio.y * 30.); - - commands.entity(entity).insert(SpriteBundle { - transform: Transform::from_translation(Vec3 { - x: pixel_position.0, - y: pixel_position.1, - z: 0., - }), - texture: tile.get_texture(&*asset_server), - ..default() - }); - } -} -- 2.43.4 From 34557956e4b5e99a2ee50ef902142c768b63acfd Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 18:59:38 +0100 Subject: [PATCH 37/38] change name variable --- crates/border-wars/src/map/generation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/border-wars/src/map/generation.rs b/crates/border-wars/src/map/generation.rs index 0d40357..f1ce9ee 100644 --- a/crates/border-wars/src/map/generation.rs +++ b/crates/border-wars/src/map/generation.rs @@ -10,7 +10,7 @@ use super::{Tile, TilePosition}; pub struct MapGenerationPlugin; /// The zoom of the map during the generation. -const MAP_GENERATION_ZOOM: f32 = 5.; +const MAP_GENERATION_SCALE: f32 = 5.; impl Plugin for MapGenerationPlugin { fn build(&self, app: &mut App) { @@ -75,7 +75,7 @@ fn generate_map( /// Returns the type of the [HexPosition] with the given noise. fn get_tile_type(position: HexPosition, noise: &Perlin) -> Tile { - let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_ZOOM; + let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_SCALE; let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]); match value { v if v <= -0.4 => Tile::Hill, -- 2.43.4 From 9d392e3b08e06cb42c4c6860807bb724f9fa036c Mon Sep 17 00:00:00 2001 From: CoCoSol007 Date: Wed, 21 Feb 2024 19:02:22 +0100 Subject: [PATCH 38/38] save --- .vscode/settings.json | 7 +++ crates/border-wars/assets/tiles/forest.png | Bin 0 -> 11194 bytes crates/border-wars/assets/tiles/grass.png | Bin 0 -> 2752 bytes crates/border-wars/assets/tiles/hill.png | Bin 0 -> 11970 bytes crates/border-wars/src/.main.rs.swp | Bin 0 -> 12288 bytes crates/border-wars/src/main.rs | 13 +++++ crates/border-wars/src/map/.renderer.rs.swp | Bin 0 -> 57344 bytes crates/border-wars/src/map/mod.rs | 1 + crates/border-wars/src/map/renderer.rs | 56 ++++++++++++++++++++ 9 files changed, 77 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 crates/border-wars/assets/tiles/forest.png create mode 100644 crates/border-wars/assets/tiles/grass.png create mode 100644 crates/border-wars/assets/tiles/hill.png create mode 100644 crates/border-wars/src/.main.rs.swp create mode 100644 crates/border-wars/src/map/.renderer.rs.swp create mode 100644 crates/border-wars/src/map/renderer.rs diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8f7aa14 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "cSpell.words": [ + "despawn", + "Despawns", + "Perlin" + ] +} \ No newline at end of file diff --git a/crates/border-wars/assets/tiles/forest.png b/crates/border-wars/assets/tiles/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..b6c89ecc56219a5ea39e4c813bb9bc2eacfdfe19 GIT binary patch literal 11194 zcmV;rD@D|aP)+nc```ci z*VY6UU#p%*WK&xb@%%IujmU^{~UY1IwJO5b?dkb)jx9n z``zmfUQI{zX%oIX`**PyYX2O2@xbS?=WE6|-}4WDxzE?!8(Uvh5PQD%6$WTJzxq4h zb1RqMh$nvHH(~Ix;DS_QuqE8*YOe5ieyi{MyS(C#7R5wAzw1}L{I3g07izD?U8?&- z+=bc>&i8)PWBRxE8$akH|CCV_{oGCqaGpSN*YE!&e^;>cGyiZ`WL55{ zuw7YShF9cL_?|p+9V(%?%Np?44qcDCT$dVosqTL`Kj*w4B~8clf2!%YffTSjg<{TB zg4rt0RTDG(I)lF4`MK}&a-Xkl%<(^+KmXpYxT6IDu03l%2;07zILRr%>ozdpbp~*- z{8MJ=Po1B2UQI{!o7Z%7|Eo>M4xq5IRbVtgR-phV_nFGyvzA9WKYP0uyPhA$ov*o% zzpK6T-)?lpovZmVueQVdEdRmrQS8OqXJgORw06GlJH1?$IlCF`>i{Th=NbV#qGmnC zUa|p>xP0&mGqsuX^X6(gqHp^qBcJ$)K_|b72^4v>lww}p2Y@;DEAZuB5OX3^>b5L{$+6;tjZfUYEnn`hoL%ASF$PKmJsc;eCifr{?n#DT?zz z%*%U-L7|w_`)uG>;%9$~eYLW!^LuXPa%Cs~I5>0Ko`8($EPWfv{c0t?A7uDf=X>oJ z1N@Vimnx1&zfexmFCuoc)K%j-uk*iUJKulDFZbbse{t>0d7ZVJ6yPg7fLAJa;RE=U zgJ1Ac?Ct!nCPRA9Z!)y^RSs%0>~RXtUqsO_>>@l|%&7_uJjdz10=$5Kdf(2rFMo4h za9$x9lc%;wP5LSzGle3LZI%gT@UBLm*t*d9Ui-xp)04;ZwE(UIlMiBX{CDixs)wAP zxuX|@y_PlmIy2k@ICLC|lidnjg%99LT7JR07ihkRrKHupgCG0w-a$QyfoF#ImCw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TBXJx|T%lj74XWuQ0zvlQaju$x=e7Rxrt^bGJ8L&1C{#=gdIsS{m zzIrRbHx%Cl{;M1n%Z5>^W`Aobx{U8vt3aw)(egRcsPfWb4KQ9G)V6Kene}w!$a4Dq zj+stS?qq<)UvT_^ql9DF7aJ!xabkJf7qkCgE-oHCmVsZ#0rvmJ$^2WLjBf%T&gTSw zM_$G#N@VtT0sBqzESW8S-AD=oEJnf`&&9{qXV=pC{fp?oOTSYVU*-6e;|#|lj_yvp z?&x(TZR8IwFCE;0flFiXUuJ+mb+X?XPSEY(-%S4j{waPfXYHTM;P)y@rq-Wk^%(M)>(yJa!rOOAi%DB~E<(bS2{_jX-LOK8Gijb`w7Ft{IHxk2K+9q^sN z!|`BM;C;u_htj#S8T6l*tI6{u2Y&{qoZI44#1c zD=P6`bAo;|;1&43z~k@ux7X4V=##=kCqQ>1zWP$JxSV6$S0$7F|NB2=U0O1v1y8_4 z2ET$q{$CtlJAuCu_yGMo1{^GgRGjBn#nF|vj=TN;xZ~gIrP+T!gSLVv;35P4#g&`b zP9rgQ7;q%KPdF+$62B~&6yzM|-|fZh_vgZED$CD4Z96ULxr2biw!s_!k|Ub|e(3Lt z#ozW~=fmtzcz^+2&G8G4YYh1HZwa`m@D6cI{c2-Ufb)KLFUQ4T2Xmw_$W`o6K4ZWI z{F?v{kblLI$I Ye{S6taNuNF_W%F@07*qoM6N<$g0sq}E&u=k literal 0 HcmV?d00001 diff --git a/crates/border-wars/assets/tiles/grass.png b/crates/border-wars/assets/tiles/grass.png new file mode 100644 index 0000000000000000000000000000000000000000..6ecf787bab29c2f7467702139bfa8f5616a74b76 GIT binary patch literal 2752 zcmV;x3P1IUP)8lQKd?)g3VbdAqfSqp;6S7s!EmE<_MHD1=|>N*a1p>VL~wYz=Ug! zi4$`bFu~wsokB=L8bN59wTzOy>^~~<<#=!Ta zpVr=;nVs+V{pZa$Rzh5yELpN-$&w{YmMmGaWXX~xOO`BIvSi7UB}}uM8Lf_K~?vGQRD-CN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(HGoN z(BCP`(!0ZucCfcN-otJ9((^vIZLODvGUxpct32vUmaOw+Z$8mhqAr;F(t8&1@%_{_ z|CtEx;d~eSeYu0q_ZtKEm2~lKS>yPgfgshxObe5YZ5(5Ar#QWHKIeg6E~k)-(`JA~ zh+N;Y5+X#HS@)4XM}(1EW8roiyMSSbB($^4nATRmO6!i_7dWB^6vvT zwTq;di^+EvQ+{J7(|-bngN=ienT>;)omY*6jh~&1pY1Cn8yi0x8!d@#$NvYgwKuUe y^Zefd8lv+b{{iU!p9U98TT^G3@3s#A6T{B&f0bBAykGyrz{p4{O4I-igZ>XZn^?mD literal 0 HcmV?d00001 diff --git a/crates/border-wars/src/.main.rs.swp b/crates/border-wars/src/.main.rs.swp new file mode 100644 index 0000000000000000000000000000000000000000..b1680bc6f16043bb6402614ba9e7fb29b39e9c9a GIT binary patch literal 12288 zcmeI2&1w`u5XUPTJsA~+5Il8Ma7H$>$x7IzR|MIFAQIGQ)LWR$)UG2tJwx|QmUUe{ z_zrsZ4SWYZcoRISZ{Q1vM{7RvF@7w1j8wy)p6;&hs`}Mw+1g&be`8&=oCeT14e-hP zh_iF=;o&6!FY+Q2^|ONfC(^x|C&G&Pr-A_@JN~ExpJQRX)c#MF##sP1egF5U;<2l2`~XBzyz286JP>| zkbvt0d^-W~WQKyL|NnP?|9?3J@R{_MG$P$3T_hbNO_RQ#1o%pNM|w>fkTytnNVBBl zq-oMo(g%9`4e1r>CFup}DJl1P2$^xnOn?b60Vco%m;e)C0!)AjFoAy}Fdl=TF}Cw5 z`_!%ZDrJ zdv`r@EajRTqFvkdYVU`h-;MieFHpwXpkPs>zMZf4bFLUwLYrur`!*9zR=vx8y$#*C^UC85eQm$J&> zPxe&4vYb+mDnx3cvMe$im+#=tP|8?iKlQ07m)ijK`n) { + event.send(StartMapGeneration { + seed: 5667, + radius: 5, + }) +} diff --git a/crates/border-wars/src/map/.renderer.rs.swp b/crates/border-wars/src/map/.renderer.rs.swp new file mode 100644 index 0000000000000000000000000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+fC3bt00k&O0SZun z0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP z3Q&Lo6rcbFC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&Lo6rcbF zC_n)UP=Epypa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&Lo6rcbFC_n)UP=Epy rpa2CZKmiI+fC3bt00k&O0SZun0u-PC1t>rP3Q&LocNYkJe^&ep(b0>H literal 0 HcmV?d00001 diff --git a/crates/border-wars/src/map/mod.rs b/crates/border-wars/src/map/mod.rs index 5265d18..73d0c06 100644 --- a/crates/border-wars/src/map/mod.rs +++ b/crates/border-wars/src/map/mod.rs @@ -2,6 +2,7 @@ pub mod generation; pub mod hex; +pub mod renderer; use bevy::prelude::*; diff --git a/crates/border-wars/src/map/renderer.rs b/crates/border-wars/src/map/renderer.rs new file mode 100644 index 0000000..ad38cce --- /dev/null +++ b/crates/border-wars/src/map/renderer.rs @@ -0,0 +1,56 @@ +//! All functions related to the rendering of the map. + +use bevy::prelude::*; + +use super::Tile; +use crate::map::TilePosition; + +/// A plugin to render the map. +pub struct RendererPlugin; + +impl Plugin for RendererPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, setup_camera).add_systems( + Update, + render_map.run_if(in_state(crate::CurrentScene::Game)), + ); + } +} + +/// Sets up the camera. +fn setup_camera(mut commands: Commands) { + commands.spawn(Camera2dBundle::default()); +} + +impl Tile { + /// Returns the texture handle of the tile. + pub fn get_texture(&self, asset_server: &AssetServer) -> Handle { + match self { + Tile::Grass => asset_server.load("tiles/grass.png"), + Tile::Forest => asset_server.load("tiles/forest.png"), + Tile::Hill => asset_server.load("tiles/hill.png"), + } + } +} + +/// Renders the map. +fn render_map( + query: Query<(Entity, &TilePosition, &Tile), Changed>, + mut commands: Commands, + asset_server: Res, +) { + for (entity, position, tile) in query.iter() { + let pixel_position_ratio = position.to_pixel_coordinates(); + let pixel_position = (50. * pixel_position_ratio.x, pixel_position_ratio.y * 30.); + + commands.entity(entity).insert(SpriteBundle { + transform: Transform::from_translation(Vec3 { + x: pixel_position.0, + y: pixel_position.1, + z: 0., + }), + texture: tile.get_texture(&*asset_server), + ..default() + }); + } +} -- 2.43.4