Compare commits

..

2 Commits

Author SHA1 Message Date
04fe103b25
Add player sprite 2021-07-16 23:33:54 -05:00
4ab62ea921
Add marshmallow sprite 2021-07-16 23:33:40 -05:00
3 changed files with 15 additions and 2 deletions

BIN
assets/marshmallow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

View File

@ -18,5 +18,6 @@ fn main() {
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins)
.add_startup_system(setup.system())
.add_startup_system(add_player.system())
.run();
}

View File

@ -31,11 +31,23 @@ pub fn setup(
}
}
pub fn add_player(mut commands: Commands) {
pub fn add_player(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
let player_sprite = materials.add(asset_server.load("marshmallow.png").into());
commands
.spawn()
.insert(Player)
.insert(Name("Player 1".to_string()));
.insert(Name("Player 1".to_string()))
.insert_bundle(SpriteBundle {
material: player_sprite,
sprite: Sprite::new(Vec2::new(64.0, 64.0)),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
..Default::default()
});
}
pub fn greet_player(