generated from tipragot/rust
save
This commit is contained in:
parent
69ccefd601
commit
81abef28a3
BIN
crates/border-wars/assets/tiles/grass/grass1.png
Normal file
BIN
crates/border-wars/assets/tiles/grass/grass1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
crates/border-wars/assets/tiles/grass/grass2.png
Normal file
BIN
crates/border-wars/assets/tiles/grass/grass2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
crates/border-wars/assets/tiles/grass/grass3.png
Normal file
BIN
crates/border-wars/assets/tiles/grass/grass3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
crates/border-wars/assets/tiles/grass/grass4.png
Normal file
BIN
crates/border-wars/assets/tiles/grass/grass4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -14,7 +14,7 @@ use self::hex::*;
|
||||||
pub type TilePosition = HexPosition<i32>;
|
pub type TilePosition = HexPosition<i32>;
|
||||||
|
|
||||||
/// The tile of the map.
|
/// The tile of the map.
|
||||||
#[derive(Component, Debug)]
|
#[derive(Component, Debug, PartialEq, Eq)]
|
||||||
pub enum Tile {
|
pub enum Tile {
|
||||||
/// The breeding tile.
|
/// The breeding tile.
|
||||||
Breeding,
|
Breeding,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::sprite::Anchor;
|
use bevy::sprite::Anchor;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
use crate::map::{Tile, TilePosition};
|
use crate::map::{Tile, TilePosition};
|
||||||
|
|
||||||
|
@ -30,6 +31,10 @@ struct TilesSize(Vec2);
|
||||||
impl Tile {
|
impl Tile {
|
||||||
/// Returns the handle of the image of the tile.
|
/// Returns the handle of the image of the tile.
|
||||||
fn get_texture(&self, asset_server: &AssetServer) -> Handle<Image> {
|
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()))
|
asset_server.load(format!("tiles/{}.png", self.to_text()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue