From ad86d5d6cc2a9ac65b6463871c307ff42a170587 Mon Sep 17 00:00:00 2001 From: Dylan Langston Date: Sun, 7 Jan 2024 23:02:22 -0500 Subject: [PATCH] Random meteor speed on explosion --- src/ViewModels/AsteroidsViewModel.zig | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ViewModels/AsteroidsViewModel.zig b/src/ViewModels/AsteroidsViewModel.zig index 308a491..175c61d 100644 --- a/src/ViewModels/AsteroidsViewModel.zig +++ b/src/ViewModels/AsteroidsViewModel.zig @@ -242,13 +242,13 @@ pub const AsteroidsViewModel = Shared.View.ViewModel.Create( if (@rem(midMeteorsCount, 2) == 0) { mediumMeteors[@intCast(midMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * -1, - @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * -1, + @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, + @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, ); } else { mediumMeteors[@intCast(midMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED, - @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED, + @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), + @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), ); } @@ -291,13 +291,13 @@ pub const AsteroidsViewModel = Shared.View.ViewModel.Create( if (@rem(midMeteorsCount, 2) == 0) { mediumMeteors[@intCast(midMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * -1, - @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * -1, + @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, + @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, ); } else { mediumMeteors[@intCast(midMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED, - @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED, + @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), + @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), ); } @@ -340,13 +340,13 @@ pub const AsteroidsViewModel = Shared.View.ViewModel.Create( if (@rem(smallMeteorsCount, 2) == 0) { smallMeteors[@intCast(smallMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * -1, - @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * -1, + @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, + @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, ); } else { smallMeteors[@intCast(smallMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED, - @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED, + @cos(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), + @sin(std.math.degreesToRadians(f32, shot.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), ); } @@ -389,13 +389,13 @@ pub const AsteroidsViewModel = Shared.View.ViewModel.Create( if (@rem(smallMeteorsCount, 2) == 0) { smallMeteors[@intCast(smallMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * -1, - @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * -1, + @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, + @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32) * -1, ); } else { smallMeteors[@intCast(smallMeteorsCount)].speed = raylib.Vector2.init( - @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED, - @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED, + @cos(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), + @sin(std.math.degreesToRadians(f32, player.rotation)) * Meteor.METEORS_SPEED * Shared.Random.Get().float(f32), ); }