This commit is contained in:
CoCo_Sol 2024-04-06 12:29:58 +02:00
parent 69ccefd601
commit 81abef28a3
6 changed files with 6 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -14,7 +14,7 @@ use self::hex::*;
pub type TilePosition = HexPosition<i32>;
/// The tile of the map.
#[derive(Component, Debug)]
#[derive(Component, Debug, PartialEq, Eq)]
pub enum Tile {
/// The breeding tile.
Breeding,

View file

@ -2,6 +2,7 @@
use bevy::prelude::*;
use bevy::sprite::Anchor;
use rand::Rng;
use crate::map::{Tile, TilePosition};
@ -30,6 +31,10 @@ struct TilesSize(Vec2);
impl Tile {
/// Returns the handle of the image of the tile.
fn get_texture(&self, asset_server: &AssetServer) -> Handle<Image> {
if *self == Self::Grass {
let random = rand::thread_rng().gen_range(1..=4);
return asset_server.load(format!("tiles/grass/grass{}.png", random));
}
asset_server.load(format!("tiles/{}.png", self.to_text()))
}