implement cruise control

This commit is contained in:
yuni 2024-05-15 04:58:55 +02:00
parent e07ad4d236
commit f94c46cce2
5 changed files with 141 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -368,6 +368,10 @@ pub fn handle_input(
}
}
}
else if keyboard_input.just_pressed(settings.key_cruise_control) {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
settings.cruise_control_active ^= true;
}
}
pub fn handle_vehicle_enter_exit(

View file

@ -405,7 +405,7 @@ pub fn apply_input_to_player(
if let Ok((player_transform, mut engine, mut angularvelocity, mut v, mut torque, bike)) = q_playercam.get_single_mut() {
// Handle key input
if focused {
if key_input.pressed(settings.key_forward) {
if key_input.pressed(settings.key_forward) || settings.cruise_control_active {
axis_input.z += 1.2;
}
if key_input.pressed(settings.key_back) {

View file

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="256"
height="256"
viewBox="0 0 67.733334 67.733334"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
sodipodi:docname="dashboard_cruise_control.svg"
xml:space="preserve"
inkscape:export-filename="../../assets/sprites/dashboard_cruise_control.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#000000"
bordercolor="#252525"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#000000"
inkscape:document-units="px"
inkscape:zoom="4.6790582"
inkscape:cx="105.5768"
inkscape:cy="127.69664"
inkscape:window-width="2880"
inkscape:window-height="1673"
inkscape:window-x="0"
inkscape:window-y="92"
inkscape:window-maximized="1"
inkscape:current-layer="g227"
showgrid="true"
inkscape:export-bgcolor="#00000000"><inkscape:grid
id="grid1"
units="px"
originx="0"
originy="0"
spacingx="0.26458334"
spacingy="0.26458334"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="8"
dotted="false"
gridanglex="30"
gridanglez="30"
visible="true" /></sodipodi:namedview><defs
id="defs1"><filter
style="color-interpolation-filters:sRGB"
id="filter1"
inkscape:label="bloom"
x="-0.12049717"
y="-0.1605499"
width="1.2409943"
height="1.3210998"><feConvolveMatrix
order="1 1"
kernelMatrix="1.0000000 "
id="feConvolveMatrix1"
result="result1"
bias="0.090000000000000024"
preserveAlpha="true"
edgeMode="none"
divisor="0" /><feGaussianBlur
stdDeviation="2"
id="feGaussianBlur1"
in="SourceGraphic" /><feComposite
id="feComposite1"
operator="arithmetic"
k1="1"
k2="0.99999999999999922"
k3="1"
k4="0"
in2="result1" /></filter></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"><g
id="g227"
style="filter:url(#filter1)"><path
style="fill:none;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path1"
inkscape:label="circle"
sodipodi:type="arc"
sodipodi:cx="35.964756"
sodipodi:cy="38.081425"
sodipodi:rx="19.068579"
sodipodi:ry="19.068579"
sodipodi:start="2.3561945"
sodipodi:end="0.78539816"
sodipodi:arc-type="arc"
d="m 22.481235,51.564946 a 19.068579,19.068579 0 0 1 0,-26.967043 19.068579,19.068579 0 0 1 26.967042,0 19.068579,19.068579 0 0 1 0,26.967043"
sodipodi:open="true" /><circle
style="fill:#007e43;fill-opacity:1;stroke:none;stroke-width:0.318295;stroke-linecap:round;stroke-linejoin:round"
id="path2"
cx="35.983334"
cy="38.100002"
r="4.0741858" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 10.583333,12.7 8.466666,8.466666 h -6.35 6.35 v -6.35"
id="path3"
sodipodi:nodetypes="ccccc" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 22.489583,51.593753 2.910416,-2.910418"
id="path5"
sodipodi:nodetypes="cc" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 49.448277,51.564944 46.566668,48.683335"
id="path6"
sodipodi:nodetypes="cc" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 22.754167,24.870834 25.4,27.516667"
id="path7" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 49.477086,24.60625 -2.910417,2.910417"
id="path8" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 16.933333,38.100002 h 4.233334"
id="path9" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 55.033336,38.100002 H 50.800002"
id="path10" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 35.983335,19.05 v 4.233334"
id="path11" /><path
style="fill:none;fill-opacity:1;stroke:#007e43;stroke-width:2.64583;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 35.983335,38.100002 -6.35,-6.35"
id="path12" /></g></g></svg>

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -117,6 +117,7 @@ pub struct Settings {
pub key_vehicle: KeyCode,
pub key_camera: KeyCode,
pub key_flashlight: KeyCode,
pub key_cruise_control: KeyCode,
pub key_rotate: KeyCode,
pub key_rotation_stabilizer: KeyCode,
pub key_mouseup: KeyCode,
@ -216,7 +217,7 @@ impl Default for Settings {
is_zooming: false,
third_person: true,
rotation_stabilizer_active: true,
cruise_control_active: true,
cruise_control_active: false,
shadows_sun: true,
shadows_pointlights: false,
shadowmap_resolution: 2048,
@ -244,6 +245,7 @@ impl Default for Settings {
key_vehicle: KeyCode::KeyQ,
key_camera: KeyCode::KeyC,
key_flashlight: KeyCode::KeyF,
key_cruise_control: KeyCode::KeyT,
key_rotate: KeyCode::KeyR,
key_rotation_stabilizer: KeyCode::KeyY,
key_mouseup: KeyCode::KeyI,