diff --git a/crates/border-wars/assets/tiles/breeding.png b/crates/border-wars/assets/tiles/breeding.png new file mode 100644 index 0000000..3c344cc Binary files /dev/null and b/crates/border-wars/assets/tiles/breeding.png differ diff --git a/crates/border-wars/assets/tiles/casern.png b/crates/border-wars/assets/tiles/casern.png new file mode 100644 index 0000000..1b1f42a Binary files /dev/null and b/crates/border-wars/assets/tiles/casern.png differ diff --git a/crates/border-wars/assets/tiles/castle.png b/crates/border-wars/assets/tiles/castle.png new file mode 100644 index 0000000..064abd3 Binary files /dev/null and b/crates/border-wars/assets/tiles/castle.png differ diff --git a/crates/border-wars/assets/tiles/forest.png b/crates/border-wars/assets/tiles/forest.png index 1e4d2d5..55c2818 100644 Binary files a/crates/border-wars/assets/tiles/forest.png and b/crates/border-wars/assets/tiles/forest.png differ diff --git a/crates/border-wars/assets/tiles/grass.png b/crates/border-wars/assets/tiles/grass.png index f7327e7..a45bd1d 100644 Binary files a/crates/border-wars/assets/tiles/grass.png and b/crates/border-wars/assets/tiles/grass.png differ diff --git a/crates/border-wars/assets/tiles/hill.png b/crates/border-wars/assets/tiles/hill.png index e8cabed..cf515be 100644 Binary files a/crates/border-wars/assets/tiles/hill.png and b/crates/border-wars/assets/tiles/hill.png differ diff --git a/crates/border-wars/assets/tiles/mine.png b/crates/border-wars/assets/tiles/mine.png new file mode 100644 index 0000000..a29775c Binary files /dev/null and b/crates/border-wars/assets/tiles/mine.png differ diff --git a/crates/border-wars/assets/tiles/outpost.png b/crates/border-wars/assets/tiles/outpost.png new file mode 100644 index 0000000..e3c8f3e Binary files /dev/null and b/crates/border-wars/assets/tiles/outpost.png differ diff --git a/crates/border-wars/assets/tiles/sawmill.png b/crates/border-wars/assets/tiles/sawmill.png new file mode 100644 index 0000000..3bceb92 Binary files /dev/null and b/crates/border-wars/assets/tiles/sawmill.png differ diff --git a/crates/border-wars/assets/tiles/tower.png b/crates/border-wars/assets/tiles/tower.png new file mode 100644 index 0000000..5962a2e Binary files /dev/null and b/crates/border-wars/assets/tiles/tower.png differ diff --git a/crates/border-wars/assets/tiles/wall.png b/crates/border-wars/assets/tiles/wall.png new file mode 100644 index 0000000..2df8dbe Binary files /dev/null and b/crates/border-wars/assets/tiles/wall.png differ diff --git a/crates/border-wars/src/map/mod.rs b/crates/border-wars/src/map/mod.rs index 9172176..a5bfdf0 100644 --- a/crates/border-wars/src/map/mod.rs +++ b/crates/border-wars/src/map/mod.rs @@ -15,6 +15,15 @@ pub type TilePosition = HexPosition; /// The tile of the map. #[derive(Component, Debug)] pub enum Tile { + /// The breeding tile. + Breeding, + + /// The Casern tile. + Casern, + + /// The castle tile. + Castle, + /// The hill tile. Hill, @@ -23,4 +32,38 @@ pub enum Tile { /// The forest tile. Forest, + + /// The mine tile. + Mine, + + /// The outpost tile + Outpost, + + /// The sawmill tile + Sawmill, + + /// The tower tile + Tower, + + /// The wall tile + Wall, +} + +impl Tile { + /// Returns the text representation of the tile. + pub fn to_text(&self) -> String { + match self { + Self::Breeding => "breeding".to_string(), + Self::Casern => "casern".to_string(), + Self::Castle => "castle".to_string(), + Self::Forest => "forest".to_string(), + Self::Grass => "grass".to_string(), + Self::Hill => "hill".to_string(), + Self::Mine => "mine".to_string(), + Self::Outpost => "outpost".to_string(), + Self::Sawmill => "sawmill".to_string(), + Self::Tower => "tower".to_string(), + Self::Wall => "wall".to_string(), + } + } } diff --git a/crates/border-wars/src/map/renderer.rs b/crates/border-wars/src/map/renderer.rs index 55fa90f..c064af0 100644 --- a/crates/border-wars/src/map/renderer.rs +++ b/crates/border-wars/src/map/renderer.rs @@ -1,5 +1,7 @@ //! All functions related to the rendering of the map. +use std::fmt::format; + use bevy::prelude::*; use bevy::sprite::Anchor; @@ -30,11 +32,7 @@ struct TilesSize(Vec2); impl Tile { /// Returns the handle of the image of the tile. fn get_texture(&self, asset_server: &AssetServer) -> Handle { - match self { - Self::Grass => asset_server.load("tiles/grass.png"), - Self::Forest => asset_server.load("tiles/forest.png"), - Self::Hill => asset_server.load("tiles/hill.png"), - } + asset_server.load(format!("tiles/{}.png", self.to_text())) } /// Returns the size of the image of the tile. @@ -43,9 +41,17 @@ impl Tile { /// this function in the future. pub const fn get_image_size(&self) -> Vec2 { match self { - Self::Grass => Vec2 { x: 184.0, y: 164.0 }, - Self::Forest => Vec2 { x: 184.0, y: 138.0 }, - Self::Hill => Vec2 { x: 184.0, y: 181.0 }, + Tile::Breeding => Vec2::new(184., 158.), + Tile::Casern => Vec2::new(184., 167.), + Tile::Castle => Vec2::new(192., 196.), + Tile::Forest => Vec2::new(184., 165.), + Tile::Grass => Vec2::new(184., 138.), + Tile::Hill => Vec2::new(184., 181.), + Tile::Mine => Vec2::new(184., 166.), + Tile::Outpost => Vec2::new(184., 208.), + Tile::Sawmill => Vec2::new(184., 138.), + Tile::Tower => Vec2::new(184., 218.), + Tile::Wall => Vec2::new(184., 186.), } } }