From 1ea451993d8a77814ba2478b0507ed388a42f4b9 Mon Sep 17 00:00:00 2001 From: Rendo Date: Sat, 15 Nov 2025 20:29:43 +0500 Subject: [PATCH] Projectile spawn --- src/projectile.rs | 17 +++++++++++---- src/ships/mod.rs | 10 ++++++--- src/ships/player.rs | 52 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/projectile.rs b/src/projectile.rs index c2c4290..8cb6b4b 100644 --- a/src/projectile.rs +++ b/src/projectile.rs @@ -14,6 +14,9 @@ pub struct Projectile { despawn_countdown: Timer, } +#[derive(Resource)] +pub struct ProjectileSprite(Handle); + pub struct ProjectilePlugin; impl Projectile { @@ -28,10 +31,15 @@ impl Projectile { impl Plugin for ProjectilePlugin { fn build(&self, app: &mut App) { - app.add_systems(FixedPreUpdate, projectile_despawn_countdown); + app.add_systems(Startup, projectile_startup) + .add_systems(FixedPreUpdate, projectile_despawn_countdown); } } +pub fn projectile_startup(mut commands: Commands, asset_server: Res) { + commands.insert_resource(ProjectileSprite(asset_server.load("projectile.png"))); +} + pub fn projectile_despawn_countdown( mut commands: Commands, time: Res