Can drop statues

This commit is contained in:
Daniel Flanagan 2024-02-02 11:35:18 -06:00
parent 458bd994d6
commit a70e59fdf8
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -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 => {