Skip to content

Commit

Permalink
Random meteor speed on explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlangston committed Jan 8, 2024
1 parent 4327776 commit ad86d5d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/ViewModels/AsteroidsViewModel.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand Down Expand Up @@ -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),
);
}

Expand Down Expand Up @@ -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),
);
}

Expand Down Expand Up @@ -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),
);
}

Expand Down

0 comments on commit ad86d5d

Please sign in to comment.