From a6622f24b5192931a76d0c0d85762e151ada3ee7 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sun, 27 Jul 2025 19:36:05 -0500 Subject: [PATCH] Add new "Wrapping" marker component Not everything needs to wrap, so I'll use a marker component for the ones that do. At the moment, I'm thinking only the player's ship will wrap around. Asteroids can be de-spawned and re-spawned, and bullets can simply evaporate. --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 688df31..30f4059 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,6 +62,10 @@ struct Rotation(f32); #[derive(Component)] struct Ship; +/// Marker for any entity that should wrap on screen edges +#[derive(Component)] +struct Wrapping; + // Data component to store color properties attached to an entity // This was easier (and imo better) than holding global consts with // UUID assets. @@ -217,7 +221,7 @@ fn apply_rotation_to_mesh(mut query: Query<(&mut Transform, &Rotation)>) { } } -fn wrap_entities(mut query: Query<&mut Position>, world_size: Res) { +fn wrap_entities(mut query: Query<&mut Position, With>, world_size: Res) { let right = world_size.width / 2.0; let left = -right; let top = world_size.height / 2.0;