add sprite reticule

This commit is contained in:
yuni 2024-04-28 01:33:27 +02:00
parent 53ada82a02
commit fc4cc8cdad
9 changed files with 381 additions and 16 deletions

64
Cargo.lock generated
View file

@ -72,6 +72,12 @@ dependencies = [
"winit",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.8.11"
@ -1503,6 +1509,15 @@ dependencies = [
"windows 0.54.0",
]
[[package]]
name = "crc32fast"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.12"
@ -1739,6 +1754,15 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984"
[[package]]
name = "fdeflate"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645"
dependencies = [
"simd-adler32",
]
[[package]]
name = "file-id"
version = "0.2.1"
@ -1766,6 +1790,16 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flate2"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "foreign-types"
version = "0.5.0"
@ -2086,6 +2120,7 @@ dependencies = [
"color_quant",
"jpeg-decoder",
"num-traits",
"png",
]
[[package]]
@ -2392,6 +2427,16 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
dependencies = [
"adler",
"simd-adler32",
]
[[package]]
name = "mio"
version = "0.8.11"
@ -2903,6 +2948,19 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "png"
version = "0.17.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1"
dependencies = [
"bitflags 1.3.2",
"crc32fast",
"fdeflate",
"flate2",
"miniz_oxide",
]
[[package]]
name = "polling"
version = "3.5.0"
@ -3286,6 +3344,12 @@ dependencies = [
"wide",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
[[package]]
name = "slab"
version = "0.4.9"

View file

@ -21,7 +21,7 @@ rust-version = "1.76.0"
[dependencies]
regex = "1"
bevy = { version = "0.13.2", default-features = false, features = ["animation", "bevy_asset", "bevy_audio", "bevy_scene", "bevy_winit", "bevy_core_pipeline", "bevy_pbr", "bevy_gltf", "bevy_render", "bevy_text", "bevy_ui", "jpeg", "multi-threaded", "tonemapping_luts", "vorbis"]}
bevy = { version = "0.13.2", default-features = false, features = ["animation", "bevy_asset", "bevy_audio", "bevy_scene", "bevy_winit", "bevy_core_pipeline", "bevy_pbr", "bevy_gltf", "bevy_render", "bevy_text", "bevy_ui", "jpeg", "multi-threaded", "png", "tonemapping_luts", "vorbis"]}
bevy_xpbd_3d = { version = "0.4.2", default-features = false, features = ["3d", "f64", "parry-f64", "parallel", "async-collider"] }
bevy_embedded_assets = { version = "0.10.2", optional = true }
fastrand = "2.0"

BIN
assets/sprites/reticule.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

74
media/reticule.svg Normal file
View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458333"
version="1.1"
id="svg1"
sodipodi:docname="reticule.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
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="5.6568543"
inkscape:cx="16.086679"
inkscape:cy="25.897786"
inkscape:window-width="2880"
inkscape:window-height="1765"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="0"
sodipodi:end="0.52359878"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="M 26.189894,13.229167 A 12.960727,12.960727 0 0 1 24.453486,19.70953" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="1.0471976"
sodipodi:end="1.5707963"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 19.70953,24.453486 a 12.960727,12.960727 0 0 1 -6.480363,1.736408" />
<circle
style="font-variation-settings:'wght' 700;fill:#9c9c9c;stroke:none;stroke-width:0.52916667;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-dasharray:none"
id="path3"
cx="13.229167"
cy="13.229167"
r="0.56732851" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

129
media/reticule2.svg Normal file
View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458333"
version="1.1"
id="svg1"
sodipodi:docname="reticule2.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
inkscape:export-filename="reticule2.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="#999999"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="5.6568543"
inkscape:cx="16.086679"
inkscape:cy="25.897786"
inkscape:window-width="2880"
inkscape:window-height="1765"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="0.26179939"
sodipodi:end="0.78539816"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 25.748268,16.58365 a 12.960727,12.960727 0 0 1 -3.354483,5.810135" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="1.3089969"
sodipodi:end="1.8325957"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 16.58365,25.748268 a 12.960727,12.960727 0 0 1 -6.7089658,0" />
<circle
style="font-variation-settings:'wght' 700;fill:#9c9c9c;stroke:none;stroke-width:0.52916667;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-dasharray:none"
id="path3"
cx="13.229167"
cy="13.229167"
r="0.56732851" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2-9"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="2.3561945"
sodipodi:end="2.8797933"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="M 4.0645491,22.393785 A 12.960727,12.960727 0 0 1 0.71006619,16.583649" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2-9-9"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="5.4977871"
sodipodi:end="6.0213859"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 22.393784,4.0645488 a 12.960727,12.960727 0 0 1 3.354484,5.810135" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2-9-9-1"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="4.4505896"
sodipodi:end="4.9741884"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 9.8746842,0.71006628 a 12.960727,12.960727 0 0 1 6.7089658,1.3e-7" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2-9-9-1-7"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="3.403392"
sodipodi:end="3.9269908"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="M 0.71006616,9.8746846 A 12.960727,12.960727 0 0 1 4.0645491,4.0645494" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

90
media/reticule3.svg Normal file
View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458333"
version="1.1"
id="svg1"
sodipodi:docname="reticule3.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
inkscape:export-filename="reticule2.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="#999999"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="5.6568543"
inkscape:cx="16.086679"
inkscape:cy="25.897786"
inkscape:window-width="2880"
inkscape:window-height="1765"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="1.3089969"
sodipodi:end="1.8325957"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 16.58365,25.748268 a 12.960727,12.960727 0 0 1 -6.7089658,0" />
<circle
style="font-variation-settings:'wght' 700;fill:#9c9c9c;stroke:none;stroke-width:0.52916667;stroke-linejoin:round;stroke-opacity:1;fill-opacity:1;stroke-dasharray:none"
id="path3"
cx="13.229167"
cy="13.229167"
r="0.56732851" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2-9-9"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="5.4977871"
sodipodi:end="6.0213859"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m 22.393784,4.0645488 a 12.960727,12.960727 0 0 1 3.354484,5.810135" />
<path
style="font-variation-settings:'wght' 700;fill:none;stroke:#c2c2c2;stroke-width:0.529167;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="path2-2-9-9-1-7"
sodipodi:type="arc"
sodipodi:cx="13.229167"
sodipodi:cy="13.229167"
sodipodi:rx="12.960727"
sodipodi:ry="12.960727"
sodipodi:start="3.403392"
sodipodi:end="3.9269908"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="M 0.71006616,9.8746846 A 12.960727,12.960727 0 0 1 4.0645491,4.0645494" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -290,23 +290,31 @@ fn setup(
});
// Add Reticule
commands.spawn((
Reticule,
ToggleableHudElement,
NodeBundle {
style: Style {
width: Val::Px(2.0),
height: Val::Px(2.0),
position_type: PositionType::Absolute,
top: Val::Vh(50.0),
left: Val::Vw(50.0),
..default()
},
visibility,
background_color: Color::rgb(0.4, 0.4, 0.6).into(),
let reticule_handle: Handle<Image> = asset_server.load("sprites/reticule3.png");
commands.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::SpaceAround,
..default()
},
));
..default()
}).with_children(|builder| {
builder.spawn((
ImageBundle {
image: UiImage::new(reticule_handle),
style: Style {
width: Val::VMin(3.0),
height: Val::VMin(3.0),
..Default::default()
},
..Default::default()
},
ToggleableHudElement,
Reticule,
));
});
// Chat "subtitles" and choices
commands.spawn(NodeBundle {