update
This commit is contained in:
@@ -136,10 +136,10 @@ fn on_resize_system(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flashlight_base_transform(width: f32, height: f32) -> BaseTransform {
|
fn flashlight_base_transform(window_width: f32, window_height: f32) -> BaseTransform {
|
||||||
let window_size = Vec2::new(width, height);
|
let window_size = Vec2::new(window_width, window_height);
|
||||||
let sprite_size = Vec2::new(101.0, 101.0);
|
let sprite_size = Vec2::new(101.0, 101.0);
|
||||||
let scale = width / 600.0;
|
let scale = window_width / 600.0;
|
||||||
let world_size = sprite_size * scale;
|
let world_size = sprite_size * scale;
|
||||||
let xoffset = window_size.x / 4.0 - 40.0;
|
let xoffset = window_size.x / 4.0 - 40.0;
|
||||||
let yoffset = 15.0;
|
let yoffset = 15.0;
|
||||||
@@ -186,6 +186,7 @@ pub(crate) enum PlayerAction {
|
|||||||
Sprint,
|
Sprint,
|
||||||
Jump,
|
Jump,
|
||||||
Interact,
|
Interact,
|
||||||
|
ToggleFlashlight
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_input(
|
pub fn handle_input(
|
||||||
@@ -214,6 +215,7 @@ pub fn handle_input(
|
|||||||
}
|
}
|
||||||
if keyboard_input.pressed(KeyCode::ShiftLeft) {
|
if keyboard_input.pressed(KeyCode::ShiftLeft) {
|
||||||
player.speed_factor = 1.35;
|
player.speed_factor = 1.35;
|
||||||
|
*action = PlayerAction::Sprint
|
||||||
} else if keyboard_input.pressed(KeyCode::ControlLeft) {
|
} else if keyboard_input.pressed(KeyCode::ControlLeft) {
|
||||||
player.speed_factor = 0.65;
|
player.speed_factor = 0.65;
|
||||||
} else {
|
} else {
|
||||||
@@ -222,6 +224,9 @@ pub fn handle_input(
|
|||||||
if keyboard_input.pressed(KeyCode::KeyE) {
|
if keyboard_input.pressed(KeyCode::KeyE) {
|
||||||
*action = PlayerAction::Interact
|
*action = PlayerAction::Interact
|
||||||
}
|
}
|
||||||
|
if keyboard_input.pressed(KeyCode::KeyA) {
|
||||||
|
*action = PlayerAction::ToggleFlashlight;
|
||||||
|
}
|
||||||
|
|
||||||
input.movement_direction = movement_direction.normalize_or_zero();
|
input.movement_direction = movement_direction.normalize_or_zero();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user