add speedometer

This commit is contained in:
yuni 2024-04-28 03:15:45 +02:00
parent 310be85e05
commit 54da276091
5 changed files with 590 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

246
media/speedometer.svg Normal file
View file

@ -0,0 +1,246 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="800"
height="200"
viewBox="0 0 211.66666 52.916667"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
sodipodi:docname="speedometer.svg"
inkscape:export-filename="speedometer.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"
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="#999999"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="1.1679082"
inkscape:cx="431.54075"
inkscape:cy="-24.402602"
inkscape:window-width="2880"
inkscape:window-height="1685"
inkscape:window-x="0"
inkscape:window-y="80"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:export-bgcolor="#00000000"
showgrid="true">
<inkscape:grid
id="grid1"
units="px"
originx="0"
originy="0"
spacingx="0.26458333"
spacingy="0.26458333"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="5"
dotted="false"
gridanglex="30"
gridanglez="30"
visible="true" />
</sodipodi:namedview>
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.70781;stroke-linejoin:round;stroke-dasharray:none"
id="rect1"
width="6.614583"
height="43.656246"
x="1.7853101e-07"
y="1.0113022e-06" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.62832;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1"
width="6.614583"
height="39.687496"
x="7.9375"
y="6.614583" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.57312;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9"
width="6.614583"
height="37.041664"
x="15.875"
y="11.906249" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.51589;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5"
width="6.6145825"
height="34.395832"
x="23.8125"
y="15.874999" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.45643;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3"
width="6.6145825"
height="31.749998"
x="31.75"
y="19.843748" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.36236;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1"
width="6.6145825"
height="27.781248"
x="39.6875"
y="23.812498" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.32952;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8"
width="6.6145821"
height="26.458334"
x="47.625"
y="26.458332" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.2613;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4"
width="6.6145821"
height="23.812502"
x="55.5625"
y="29.104164" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.18917;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6"
width="6.6145821"
height="21.166668"
x="63.5"
y="31.749998" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.11237;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5"
width="6.6145816"
height="18.520836"
x="71.4375"
y="34.395832" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.0719;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1"
width="6.6145816"
height="17.19792"
x="79.375"
y="35.718746" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.02985;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7"
width="6.6145816"
height="15.875003"
x="87.3125"
y="37.041664" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.986008;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5"
width="6.6145811"
height="14.552084"
x="95.25"
y="38.364582" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940118;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3"
width="6.6145811"
height="13.229167"
x="103.1875"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940118;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-1"
width="6.6145806"
height="13.229167"
x="111.125"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940118;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-8"
width="6.6145806"
height="13.229167"
x="119.0625"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940117;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-9"
width="6.6145806"
height="13.229167"
x="127"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940117;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6"
width="6.6145802"
height="13.229167"
x="134.9375"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940117;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-3"
width="6.6145802"
height="13.229167"
x="142.875"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940119;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-86"
width="6.6145954"
height="13.229167"
x="150.81248"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940119;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-0"
width="6.6145949"
height="13.229167"
x="158.74998"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940119;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-4"
width="6.6145949"
height="13.229167"
x="166.68748"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940118;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-1-8"
width="6.6145949"
height="13.229167"
x="174.62498"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940118;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-8-8"
width="6.6145945"
height="13.229167"
x="182.56248"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940118;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-9-8"
width="6.6145945"
height="13.229167"
x="190.49998"
y="39.6875" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940117;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9"
width="6.6145792"
height="13.229167"
x="198.4375"
y="39.687496" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.9 KiB

295
media/speedometer2.svg Normal file
View file

@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="1000"
height="200"
viewBox="0 0 264.58333 52.916667"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
sodipodi:docname="speedometer2.svg"
inkscape:export-filename="speedometer.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"
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="#999999"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="2.3358165"
inkscape:cx="415.70046"
inkscape:cy="74.706211"
inkscape:window-width="2880"
inkscape:window-height="1685"
inkscape:window-x="0"
inkscape:window-y="80"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:export-bgcolor="#00000000"
showgrid="true">
<inkscape:grid
id="grid1"
units="px"
originx="0"
originy="0"
spacingx="0.26458333"
spacingy="0.26458333"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="5"
dotted="false"
gridanglex="30"
gridanglez="30"
visible="true" />
</sodipodi:namedview>
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.594583;stroke-linejoin:round;stroke-dasharray:none"
id="rect1"
width="6.614583"
height="5.2916651"
x="5.3530993e-08"
y="47.624996" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.594579;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1"
width="6.614583"
height="5.2916675"
x="7.9374995"
y="47.624996" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.664764;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9"
width="6.614583"
height="6.6145825"
x="15.874999"
y="46.302082" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.664761;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5"
width="6.6145825"
height="6.6145835"
x="23.8125"
y="46.302082" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.728215;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3"
width="6.6145825"
height="7.9375"
x="31.75"
y="44.979164" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.728212;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1"
width="6.6145825"
height="7.9375"
x="39.6875"
y="44.979164" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.786555;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8"
width="6.6145821"
height="9.2604189"
x="47.625"
y="43.656246" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.786559;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4"
width="6.6145821"
height="9.2604189"
x="55.5625"
y="43.656246" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.84087;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6"
width="6.6145821"
height="10.583335"
x="63.5"
y="42.333332" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.840873;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5"
width="6.6145816"
height="10.583337"
x="71.4375"
y="42.333332" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.891875;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1"
width="6.6145816"
height="11.906252"
x="79.375"
y="41.010414" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.94012;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7"
width="6.6145797"
height="13.229167"
x="87.3125"
y="39.687496" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.940122;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5"
width="6.6145811"
height="13.229168"
x="95.25"
y="39.687496" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:0.986006;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3"
width="6.6145811"
height="14.552086"
x="103.1875"
y="38.364582" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.02985;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-1"
width="6.6145806"
height="15.875004"
x="111.125"
y="37.041664" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.02985;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-8"
width="6.6145806"
height="15.875003"
x="119.0625"
y="37.041664" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.0719;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-9"
width="6.6145806"
height="17.19792"
x="127"
y="35.718746" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.11236;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6"
width="6.6145802"
height="18.520832"
x="134.9375"
y="34.395832" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.11236;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-3"
width="6.6145802"
height="18.520832"
x="142.875"
y="34.395832" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.15141;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-86"
width="6.6145954"
height="19.843752"
x="150.81248"
y="33.072914" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.18917;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-0"
width="6.6145949"
height="21.166664"
x="158.74998"
y="31.749998" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.22577;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-4"
width="6.6145949"
height="22.489586"
x="166.68748"
y="30.427082" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.2613;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-1-8"
width="6.6145949"
height="23.812502"
x="174.62498"
y="29.104164" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.29586;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-8-8"
width="6.6145945"
height="25.135418"
x="182.56248"
y="27.781248" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.36236;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-9-8"
width="6.6145945"
height="27.781252"
x="190.49998"
y="25.135416" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.42576;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9"
width="6.6145792"
height="30.427082"
x="198.4375"
y="22.489582" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.48646;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4"
width="6.6145792"
height="33.072914"
x="206.375"
y="19.843748" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.54477;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0"
width="6.6145792"
height="35.718746"
x="214.31248"
y="17.197916" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.60096;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4"
width="6.6145792"
height="38.364578"
x="222.24998"
y="14.552082" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.65525;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4"
width="6.6145792"
height="41.010414"
x="230.05521"
y="11.906249" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.73349;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4-2"
width="6.6145792"
height="44.97916"
x="238.125"
y="7.937501" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.80835;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4-2-5"
width="6.6145792"
height="48.94791"
x="246.0625"
y="3.9687498" />
<rect
style="font-variation-settings:'wght' 700;fill:#bf1351;stroke:none;stroke-width:1.88023;stroke-linejoin:round;stroke-dasharray:none"
id="rect1-1-9-5-3-1-8-4-6-5-1-7-5-3-6-9-4-0-4-4-2-5-2"
width="6.6145792"
height="52.91666"
x="253.99998"
y="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -74,6 +74,7 @@ impl Plugin for HudPlugin {
#[derive(Component)] struct NodeChoiceText;
#[derive(Component)] struct NodeCurrentChatLine;
#[derive(Component)] struct Reticule;
#[derive(Component)] struct Speedometer;
#[derive(Component)] pub struct ToggleableHudElement;
#[derive(Component)] pub struct ToggleableHudMapElement;
#[derive(Component)] struct Selectagon;
@ -319,6 +320,36 @@ fn setup(
));
});
// Add Speedometer
let reticule_handle: Handle<Image> = asset_server.load("sprites/speedometer.png");
commands.spawn((
NodeBundle {
style: Style {
width: Val::VMin(10.0),
height: Val::Percent(100.0),
align_items: AlignItems::End,
overflow: Overflow::clip(),
..default()
},
visibility,
..default()
},
Speedometer,
ToggleableHudElement,
)).with_children(|builder| {
builder.spawn((
ImageBundle {
image: UiImage::new(reticule_handle),
style: Style {
width: Val::VMin(50.0),
height: Val::VMin(10.0),
..Default::default()
},
..Default::default()
},
));
});
// Chat "subtitles" and choices
commands.spawn(NodeBundle {
style: Style {
@ -395,6 +426,7 @@ fn update_hud(
mut q_node_currentline: Query<&mut Text, (With<NodeCurrentChatLine>, Without<NodeHud>, Without<NodeConsole>, Without<NodeChoiceText>)>,
query_all_actors: Query<&actor::Actor>,
settings: Res<var::Settings>,
mut q_speedometer: Query<&mut Style, With<Speedometer>>,
q_target: Query<(&IsClickable, Option<&Position>, Option<&LinearVelocity>), With<IsTargeted>>,
) {
// TODO only when hud is actually on
@ -494,6 +526,14 @@ fn update_hud(
let speed_readable = nature::readable_distance(speed);
text.sections[14].value = format!("\n{speed_readable}/s\n{gforce:.1}g{dev_speed}");
if let Ok(mut speedometer) = q_speedometer.get_single_mut() {
let custom_c = nature::C / 1000.0;
let fraction = nature::lorenz_factor_custom_c(custom_c - speed, custom_c) as f32;
info!(fraction);
let wid = (fraction * 100.0).clamp(0.0, 100.0);
speedometer.width = Val::VMin(wid);
}
if target_multiple {
text.sections[15].value = "\n\nERROR: MULTIPLE TARGETS".to_string();
}

View file

@ -19,6 +19,7 @@ pub const LIGHTYEAR2METER: f64 = 9_460_730_472_580_800.0;
pub const PARSEC2METER: f64 = 3.0857e16;
pub const DIST_JUPTER_SUN: f64 = 778479.0e6;
pub const EARTH_GRAVITY: f32 = 9.81;
pub const C: f64 = 299792458.0; // m/s
pub const SOL_RADIUS: f64 = 696_300_000.0;
pub const JUPITER_RADIUS: f64 = 71_492_000.0;
@ -118,3 +119,11 @@ pub fn readable_distance(distance: f64) -> String {
}
return format!("{distance:.1}m");
}
pub fn lorenz_factor(speed: f64) -> f64 {
(1.0 - (speed.powf(2.0) / C.powf(2.0))).sqrt()
}
pub fn lorenz_factor_custom_c(speed: f64, c: f64) -> f64 {
(1.0 - (speed.powf(2.0) / c.powf(2.0))).sqrt()
}