Skip to content

Commit

Permalink
Max_player_projectiles should be an unsigned integer. This isnt javas…
Browse files Browse the repository at this point in the history
…cript
  • Loading branch information
varoonp123 committed Jan 15, 2024
1 parent 2c3e818 commit 78abd30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/game/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct GameParametersResource {
pub camera_zoom_out_scale: f32,
/// Maximum possible projectiles for 1 of the player/mobs shots. Mainly kept low for perf and as
/// a hard cap (along with fire rate) on how much of a "bullet hell" each mob/player creates.
pub max_player_projectiles: f32,
pub max_player_projectiles: u16,
/// Maximum possible speed of an entity
pub max_speed: f32,
/// Maximum angle between the first and last projectile
Expand Down
9 changes: 5 additions & 4 deletions src/weapon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,19 @@ pub fn update_weapon_system(

pub(crate) trait WeaponProjectileInitialVelocitiesExt {
/// The initial velocities of `n` projectiles using existing/'partially evaluated' params.
/// Could be evenly spaced, or something else based on the struct params.
fn get_linvels(&self, max_projectiles: f32) -> Vec<Vec2>;
/// Could be evenly spaced, or something else based on the struct params. max_projectiles
/// should be greater than 0.
fn get_linvels(&self, max_projectiles: u16) -> Vec<Vec2>;
}
impl WeaponProjectileInitialVelocitiesExt for WeaponProjectileData {
fn get_linvels(&self, max_projectiles: f32) -> Vec<Vec2> {
fn get_linvels(&self, max_projectiles: u16) -> Vec<Vec2> {
match &self.spread_pattern {
SpreadPattern::Arc(arc_pattern) => {
// Get the segment of a spread angle
let spread_angle_segment = {
// percentage of the game's maximum amount of projectiles being spawned
let total_projectiles_percent =
(self.count as f32 - 1.) / (max_projectiles - 1.);
(self.count as f32 - 1.) / (max_projectiles as f32 - 1.);
// indicates the angle between the first and last projectile
let spread_arc = arc_pattern
.max_spread
Expand Down

0 comments on commit 78abd30

Please sign in to comment.