forked from tutorials/rust-sokoban
Boxes don't need animation
This commit is contained in:
parent
73a0b08cfd
commit
9198ca096b
@ -6,6 +6,8 @@ use std::fmt::Display;
|
|||||||
pub enum BoxColor {
|
pub enum BoxColor {
|
||||||
Red,
|
Red,
|
||||||
Blue,
|
Blue,
|
||||||
|
Green,
|
||||||
|
Brown,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for BoxColor {
|
impl Display for BoxColor {
|
||||||
@ -13,6 +15,8 @@ impl Display for BoxColor {
|
|||||||
fmt.write_str(match self {
|
fmt.write_str(match self {
|
||||||
BoxColor::Red => "red",
|
BoxColor::Red => "red",
|
||||||
BoxColor::Blue => "blue",
|
BoxColor::Blue => "blue",
|
||||||
|
BoxColor::Green => "green",
|
||||||
|
BoxColor::Brown => "brown",
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -45,11 +45,8 @@ pub fn create_floor(world: &mut World, position: Position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_box(world: &mut World, position: Position, color: BoxColor) {
|
pub fn create_box(world: &mut World, position: Position, color: BoxColor) {
|
||||||
let mut sprites: Vec<String> = vec![];
|
let path = format!("/images/box_{}.png", color);
|
||||||
for x in 1..=2 {
|
static_entity(world, position, 10, &path)
|
||||||
sprites.push(format!("/images/box_{}_{}.png", color, x));
|
|
||||||
}
|
|
||||||
animated_entity(world, position, 10, sprites)
|
|
||||||
.with(Box { color })
|
.with(Box { color })
|
||||||
.with(Movable)
|
.with(Movable)
|
||||||
.build();
|
.build();
|
||||||
|
@ -26,7 +26,7 @@ pub fn load_map(world: &mut World, map_string: String) {
|
|||||||
}
|
}
|
||||||
"*" => {
|
"*" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
create_box(world, position, BoxColor::Blue);
|
create_box(world, position, BoxColor::Brown);
|
||||||
}
|
}
|
||||||
"+" => {
|
"+" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
@ -34,7 +34,7 @@ pub fn load_map(world: &mut World, map_string: String) {
|
|||||||
}
|
}
|
||||||
"%" => {
|
"%" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
create_box_spot(world, position, BoxColor::Blue);
|
create_box_spot(world, position, BoxColor::Brown);
|
||||||
}
|
}
|
||||||
"=" => {
|
"=" => {
|
||||||
create_floor(world, position);
|
create_floor(world, position);
|
||||||
|
Loading…
Reference in New Issue
Block a user