From 54aab50c3b78623c25c446325622cb1053809e30 Mon Sep 17 00:00:00 2001 From: CoCo_Sol Date: Thu, 25 May 2023 18:55:52 +0200 Subject: [PATCH] map generique --- src/map.rs | 50 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/src/map.rs b/src/map.rs index b83a410..92c0671 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,6 +1,6 @@ //! Contiens tous ce qui est relatif à la carte du jeu. -use crate::{PlayerId, Position}; +use crate::Position; use bevy::prelude::{Commands, Component}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Component)] @@ -76,53 +76,21 @@ pub enum Tile { /// Permet de crée des entité representant les cases d'une map, sur une longueur et langueur donné. /// Donner une longueur impaire. -pub fn init_map( - longueur: u8, - largeur: u8, - mut commands: Commands, - id_joueur1: PlayerId, - id_joueur2: PlayerId, -) { +pub fn init_map(longueur: u8, largeur: u8, mut commands: Commands) { for y in 0..longueur { for x in 0..largeur { if y % 2 != 0 && x == longueur { } else { let mut curent_type = Tile::Grass; - let mut curent_id = None; - if x == 1 && y == 4 { - curent_type = Tile::Castle; - curent_id = Some(id_joueur1); - } else if x == longueur && y == 4 { - curent_type = Tile::Castle; - curent_id = Some(id_joueur2); - } else { - match (x, y) { - (0, 5) | (1, 5) | (2, 4) | (1, 3) | (0, 3) => { - curent_type = Tile::Grass; - curent_id = Some(id_joueur1) - } - - (9, 5) | (8, 5) | (8, 4) | (9, 3) | (8, 3) => { - curent_type = Tile::Grass; - curent_id = Some(id_joueur2) - } - - _ => { - if rand::random() { - if rand::random() { - curent_type = Tile::Forest - } else { - curent_type = Tile::Hill - } - } - } + if rand::random() { + if rand::random() { + curent_type = Tile::Forest + } else { + curent_type = Tile::Hill } } - if let Some(id) = curent_id { - commands.spawn((curent_type, id, Position { x, y })); - } else { - commands.spawn((curent_type, Position { x, y })); - } + + commands.spawn((curent_type, Position { x, y })); } } }