forked from tutorials/rust-sokoban
60 lines
1.5 KiB
Rust
60 lines
1.5 KiB
Rust
|
use crate::components::*;
|
||
|
use specs::{Builder, World, WorldExt};
|
||
|
|
||
|
pub fn create_wall(world: &mut World, position: Position) {
|
||
|
world
|
||
|
.create_entity()
|
||
|
.with(Position { z: 10, ..position })
|
||
|
.with(Renderable {
|
||
|
path: "/images/wall.png".to_string(),
|
||
|
})
|
||
|
.with(Wall {})
|
||
|
.with(Immovable)
|
||
|
.build();
|
||
|
}
|
||
|
|
||
|
pub fn create_floor(world: &mut World, position: Position) {
|
||
|
world
|
||
|
.create_entity()
|
||
|
.with(Position { z: 5, ..position })
|
||
|
.with(Renderable {
|
||
|
path: "/images/floor.png".to_string(),
|
||
|
})
|
||
|
.build();
|
||
|
}
|
||
|
|
||
|
pub fn create_box(world: &mut World, position: Position) {
|
||
|
world
|
||
|
.create_entity()
|
||
|
.with(Position { z: 10, ..position })
|
||
|
.with(Renderable {
|
||
|
path: "/images/box.png".to_string(),
|
||
|
})
|
||
|
.with(Box {})
|
||
|
.with(Movable)
|
||
|
.build();
|
||
|
}
|
||
|
|
||
|
pub fn create_box_spot(world: &mut World, position: Position) {
|
||
|
world
|
||
|
.create_entity()
|
||
|
.with(Position { z: 9, ..position })
|
||
|
.with(Renderable {
|
||
|
path: "/images/box_spot.png".to_string(),
|
||
|
})
|
||
|
.with(BoxSpot {})
|
||
|
.build();
|
||
|
}
|
||
|
|
||
|
pub fn create_player(world: &mut World, position: Position) {
|
||
|
world
|
||
|
.create_entity()
|
||
|
.with(Position { z: 10, ..position })
|
||
|
.with(Renderable {
|
||
|
path: "/images/player.png".to_string(),
|
||
|
})
|
||
|
.with(Player {})
|
||
|
.with(Movable)
|
||
|
.build();
|
||
|
}
|