Skip to content

Commit

Permalink
start pc crate map v2
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyTurtleDev committed May 12, 2023
1 parent d193208 commit 7f9e349
Showing 1 changed file with 57 additions and 3 deletions.
60 changes: 57 additions & 3 deletions pc/src/tiles.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use crate::GetTexture;
pub use m3_map::tiles::MapBaseTile;
use m3_map::tiles::{ObjectTile, PlayerTile, Tiles};
use tetra::{graphics::Texture, Context};

///Store all Textures
pub struct Textures {
grass: Texture,
stone: Texture
stone: Texture,
player1_car: Texture,
player2_car: Texture,
player3_car: Texture,
player4_car: Texture,
global_goal: Texture,
}

impl Textures {
Expand All @@ -19,9 +25,32 @@ impl Textures {
.unwrap(),
stone: Texture::from_encoded(
ctx,
include_bytes!("../assets/img/BaseTiles/stone.png")
include_bytes!("../assets/img/ObjectTiles/stone.png")
)
.unwrap(),
player1_car: Texture::from_encoded(
ctx,
include_bytes!("../assets/img/Player/player1_car.png")
).unwrap(),
player2_car: Texture::from_encoded(
ctx,
include_bytes!("../assets/img/Player/player2_car.png")
).unwrap(),
player3_car: Texture::from_encoded(
ctx,
include_bytes!("../assets/img/Player/player3_car.png")
).unwrap(),
player4_car: Texture::from_encoded(
ctx,
include_bytes!("../assets/img/Player/player4_car.png")
)
.unwrap(),
global_goal: Texture::from_encoded(
ctx,
include_bytes!("../assets/img/Player/goal.png")
)
.unwrap()

}
}
}
Expand All @@ -30,12 +59,37 @@ impl<'a> GetTexture<'a> for MapBaseTile {
///get Texture assioated with this Tile
fn texture(&self, textures: &'a Textures) -> &'a Texture {
match self {
Self::Grass => &textures.grass,
Self::Grass => &textures.grass
}
}
}

impl<'a> GetTexture<'a> for ObjectTile {
///get Texture assioated with this Tile
fn texture(&self, textures: &'a Textures) -> &'a Texture {
match self {
Self::Stone => &textures.stone
}
}
}

impl<'a> GetTexture<'a> for PlayerTile {
///get Texture assioated with this Tile
fn texture(&self, textures: &'a Textures) -> &'a Texture {
match self {
Self::Car1 => &textures.player1_car,
Self::Car2 => &textures.player1_car,
Self::Car3 => &textures.player1_car,
Self::Car4 => &textures.player1_car,
Self::GlobalGoal => &textures.global_goal,
}
}
}

impl<'a> GetTexture<'a> for Tile {
match Tile
}

#[cfg(test)]
mod tests {
use crate::tiles::Textures;
Expand Down

0 comments on commit 7f9e349

Please sign in to comment.