Can drop statues
This commit is contained in:
parent
458bd994d6
commit
a70e59fdf8
1 changed files with 27 additions and 14 deletions
|
@ -44,25 +44,24 @@ fn controls(
|
|||
mut commands: Commands,
|
||||
mut query: Query<(&mut TextureAtlasSprite, &mut Heading, Entity), With<Player>>,
|
||||
input: Res<Input<KeyCode>>,
|
||||
mouse_input: Res<Input<MouseButton>>,
|
||||
assets: Res<AssetLoader>,
|
||||
q_windows: Query<&Window, With<PrimaryWindow>>,
|
||||
q_camera: Query<(&Camera, &GlobalTransform), With<Camera>>,
|
||||
) {
|
||||
let (mut sprite, mut heading, player_entity) = query.single_mut();
|
||||
let (camera, camera_transform) = q_camera.single();
|
||||
**heading = Vec2::ZERO;
|
||||
for key in input.get_just_pressed() {
|
||||
match key {
|
||||
KeyCode::Space => {
|
||||
let child = commands
|
||||
.spawn(AudioSourceBundle {
|
||||
source: assets.sounds.meow.clone(),
|
||||
settings: PlaybackSettings::DESPAWN.with_spatial(false),
|
||||
})
|
||||
.id();
|
||||
commands.entity(player_entity).push_children(&[child]);
|
||||
}
|
||||
KeyCode::Key1 => {
|
||||
if let Some(position) = q_windows.single().cursor_position() {
|
||||
let spos = position.extend(0.);
|
||||
for button in mouse_input.get_just_pressed() {
|
||||
match button {
|
||||
MouseButton::Left => {
|
||||
if let Some(world_position) = q_windows
|
||||
.single()
|
||||
.cursor_position()
|
||||
.and_then(|cursor| camera.viewport_to_world(camera_transform, cursor))
|
||||
.map(|ray| ray.origin.truncate())
|
||||
{
|
||||
let spos = world_position.extend(0.);
|
||||
commands.spawn((
|
||||
Statue,
|
||||
SpriteSheetBundle {
|
||||
|
@ -77,6 +76,20 @@ fn controls(
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
for key in input.get_just_pressed() {
|
||||
match key {
|
||||
KeyCode::Space => {
|
||||
let child = commands
|
||||
.spawn(AudioSourceBundle {
|
||||
source: assets.sounds.meow.clone(),
|
||||
settings: PlaybackSettings::DESPAWN.with_spatial(false),
|
||||
})
|
||||
.id();
|
||||
commands.entity(player_entity).push_children(&[child]);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
for key in input.get_pressed() {
|
||||
match key {
|
||||
KeyCode::A | KeyCode::Left => {
|
||||
|
|
Loading…
Reference in a new issue