diff --git a/src/config.rs b/src/config.rs index 51b3ac8..e80e187 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,6 +13,7 @@ pub(crate) const BACKGROUND_COLOR: Color = Color::srgb(0.3, 0.3, 0.3); pub(crate) const PLAYER_SHIP_COLOR: Color = Color::srgb(1.0, 1.0, 1.0); pub(crate) const SHIP_THRUSTER_COLOR_ACTIVE: Color = Color::srgb(1.0, 0.2, 0.2); pub(crate) const SHIP_THRUSTER_COLOR_INACTIVE: Color = Color::srgb(0.5, 0.5, 0.5); +pub(crate) const SHIP_FIRE_RATE: f32 = 3.0; // in bullets-per-second pub(crate) const ASTEROID_SMALL_COLOR: Color = Color::srgb(1.0, 0., 0.); pub(crate) const BULLET_COLOR: Color = Color::srgb(0.0, 0.1, 0.9); // TODO: asteroid medium & large diff --git a/src/lib.rs b/src/lib.rs index c477ae4..395c615 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ use crate::config::{ SHIP_THRUSTER_COLOR_INACTIVE, }; use crate::machinery::AsteroidSpawner; -use crate::objects::{Bullet, Ship}; +use crate::objects::{Bullet, Ship, Weapon}; use crate::physics::AngularVelocity; use bevy::prelude::*; @@ -160,19 +160,25 @@ fn input_ship_rotation( /// tick those timers. Maybe this system? fn input_ship_shoot( keyboard_input: Res>, - ship: Single<(&Transform, &physics::Velocity), With>, + ship: Single<(&Transform, &physics::Velocity, &mut Weapon), With>, game_assets: Res, mut commands: Commands, + time: Res