50 lines
1.3 KiB
Rust
50 lines
1.3 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::new("/images/wall.png"))
|
|
.with(Wall {})
|
|
.with(Immovable)
|
|
.build();
|
|
}
|
|
|
|
pub fn create_floor(world: &mut World, position: Position) {
|
|
world
|
|
.create_entity()
|
|
.with(Position { z: 5, ..position })
|
|
.with(Renderable::new("/images/floor.png"))
|
|
.build();
|
|
}
|
|
|
|
pub fn create_box(world: &mut World, position: Position) {
|
|
world
|
|
.create_entity()
|
|
.with(Position { z: 10, ..position })
|
|
.with(Renderable::new("/images/box.png"))
|
|
.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::new("/images/box_spot.png"))
|
|
.with(BoxSpot {})
|
|
.build();
|
|
}
|
|
|
|
pub fn create_player(world: &mut World, position: Position) {
|
|
world
|
|
.create_entity()
|
|
.with(Position { z: 10, ..position })
|
|
.with(Renderable::new("/images/player.png"))
|
|
.with(Player {})
|
|
.with(Movable)
|
|
.build();
|
|
}
|