Browse Source

Boxes don't need animation

master
Timothy Warren 1 year ago
parent
commit
9198ca096b
  1. 4
      src/components.rs
  2. 7
      src/entities.rs
  3. 4
      src/map.rs

4
src/components.rs

@ -6,6 +6,8 @@ use std::fmt::Display;
pub enum BoxColor {
Red,
Blue,
Green,
Brown,
}
impl Display for BoxColor {
@ -13,6 +15,8 @@ impl Display for BoxColor {
fmt.write_str(match self {
BoxColor::Red => "red",
BoxColor::Blue => "blue",
BoxColor::Green => "green",
BoxColor::Brown => "brown",
})?;
Ok(())

7
src/entities.rs

@ -45,11 +45,8 @@ pub fn create_floor(world: &mut World, position: Position) {
}
pub fn create_box(world: &mut World, position: Position, color: BoxColor) {
let mut sprites: Vec<String> = vec![];
for x in 1..=2 {
sprites.push(format!("/images/box_{}_{}.png", color, x));
}
animated_entity(world, position, 10, sprites)
let path = format!("/images/box_{}.png", color);
static_entity(world, position, 10, &path)
.with(Box { color })
.with(Movable)
.build();

4
src/map.rs

@ -26,7 +26,7 @@ pub fn load_map(world: &mut World, map_string: String) {
}
"*" => {
create_floor(world, position);
create_box(world, position, BoxColor::Blue);
create_box(world, position, BoxColor::Brown);
}
"+" => {
create_floor(world, position);
@ -34,7 +34,7 @@ pub fn load_map(world: &mut World, map_string: String) {
}
"%" => {
create_floor(world, position);
create_box_spot(world, position, BoxColor::Blue);
create_box_spot(world, position, BoxColor::Brown);
}
"=" => {
create_floor(world, position);

Loading…
Cancel
Save