added aiming
This commit is contained in:
parent
6d0012c782
commit
0d07fa2329
@ -47,6 +47,8 @@ pub fn capture_input(
|
|||||||
front: keyboard_input.pressed(KeyCode::W),
|
front: keyboard_input.pressed(KeyCode::W),
|
||||||
back: keyboard_input.pressed(KeyCode::S),
|
back: keyboard_input.pressed(KeyCode::S),
|
||||||
sprint: keyboard_input.pressed(KeyCode::ShiftLeft),
|
sprint: keyboard_input.pressed(KeyCode::ShiftLeft),
|
||||||
|
lean_left: keyboard_input.pressed(KeyCode::Q),
|
||||||
|
lean_right: keyboard_input.pressed(KeyCode::E),
|
||||||
};
|
};
|
||||||
move_player(player_movement_input, player_query, time);
|
move_player(player_movement_input, player_query, time);
|
||||||
}
|
}
|
||||||
|
@ -1 +1,26 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use crate::comps::core::markers::player::PlayerHand;
|
||||||
|
|
||||||
|
pub fn capture_hand_usage(
|
||||||
|
mouse_buttons: Res<Input<MouseButton>>,
|
||||||
|
mut query: Query<&mut Transform, With<PlayerHand>>,
|
||||||
|
time: Res<Time>,
|
||||||
|
) {
|
||||||
|
for mut transform in query.iter_mut() {
|
||||||
|
if mouse_buttons.pressed(MouseButton::Left) {
|
||||||
|
if mouse_buttons.just_pressed(MouseButton::Left) {
|
||||||
|
// First shot
|
||||||
|
} else {
|
||||||
|
// All other shots
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// For now just set the transforms
|
||||||
|
if mouse_buttons.pressed(MouseButton::Right) {
|
||||||
|
*transform = Transform::from_xyz(0.0, -0.35, -1.5);
|
||||||
|
} else {
|
||||||
|
*transform = Transform::from_xyz(0.6, -0.45, -2.7)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -96,8 +96,10 @@ pub struct PlayerMovementInput {
|
|||||||
pub front: bool,
|
pub front: bool,
|
||||||
/// S KEY
|
/// S KEY
|
||||||
pub back: bool,
|
pub back: bool,
|
||||||
// LShift (SPRINTING)
|
/// LShift (SPRINTING)
|
||||||
pub sprint: bool,
|
pub sprint: bool,
|
||||||
|
pub lean_left: bool,
|
||||||
|
pub lean_right: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies game logic to determine how player should move.
|
/// Applies game logic to determine how player should move.
|
||||||
@ -204,6 +206,10 @@ pub fn move_player(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if player_movement_input.lean_left {
|
||||||
|
//player_transform.rotation =
|
||||||
|
} else {}
|
||||||
|
|
||||||
if player_movement_input.up && player_linear_y_state.is_grounded(&PLAYER_JUMP_COOLDOWN_MS) {
|
if player_movement_input.up && player_linear_y_state.is_grounded(&PLAYER_JUMP_COOLDOWN_MS) {
|
||||||
player_external_force.impulse = Vec3::new(0.0, PLAYER_JUMP_FORCE, 0.0);
|
player_external_force.impulse = Vec3::new(0.0, PLAYER_JUMP_FORCE, 0.0);
|
||||||
*player_linear_y_state = PlayerLinearYState::Jumping;
|
*player_linear_y_state = PlayerLinearYState::Jumping;
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
follow_cursor_with_camera, update_camera_vertical_position, MouseMovementSettings,
|
follow_cursor_with_camera, update_camera_vertical_position, MouseMovementSettings,
|
||||||
},
|
},
|
||||||
player_vertical_sync::sync_player_y_state,
|
player_vertical_sync::sync_player_y_state,
|
||||||
spawn_player::spawn_player,
|
spawn_player::spawn_player, hands::capture_hand_usage,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -25,16 +25,19 @@ pub fn load_scene(application: &mut App) {
|
|||||||
application.add_systems(Startup, spawn_ground);
|
application.add_systems(Startup, spawn_ground);
|
||||||
application.add_systems(Startup, spawn_obstacles);
|
application.add_systems(Startup, spawn_obstacles);
|
||||||
application.add_systems(Startup, spawn_player);
|
application.add_systems(Startup, spawn_player);
|
||||||
application.add_systems(PostStartup, spawn_firearm_on_player_hands.after(spawn_player));
|
application.add_systems(
|
||||||
|
PostStartup,
|
||||||
|
spawn_firearm_on_player_hands.after(spawn_player),
|
||||||
|
);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
application.add_systems(Update, capture_input);
|
application.add_systems(Update, capture_input);
|
||||||
//application.add_systems(Update, sync_camera_to_player);
|
|
||||||
application.add_systems(Update, capture_cursor);
|
application.add_systems(Update, capture_cursor);
|
||||||
application.add_systems(Update, sync_player_y_state);
|
application.add_systems(Update, sync_player_y_state);
|
||||||
application.add_systems(Update, follow_cursor_with_camera);
|
application.add_systems(Update, follow_cursor_with_camera);
|
||||||
application.add_systems(Update, asset_loaded);
|
application.add_systems(Update, asset_loaded);
|
||||||
application.add_systems(Update, update_camera_vertical_position);
|
application.add_systems(Update, update_camera_vertical_position);
|
||||||
|
application.add_systems(Update, capture_hand_usage);
|
||||||
|
|
||||||
application.add_systems(Startup, setup_lighting);
|
application.add_systems(Startup, setup_lighting);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ pub fn spawn_obstacles(
|
|||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
asset_server: Res<AssetServer>,
|
//asset_server: Res<AssetServer>,
|
||||||
) {
|
) {
|
||||||
let box_1_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
let box_1_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
||||||
let box_2_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
let box_2_mesh = shape::Box::new(3.0, 7.0, 3.0).into();
|
||||||
|
Loading…
Reference in New Issue
Block a user