diff --git a/src/Models/Meteor.zig b/src/Models/Meteor.zig index b59a0c9..77550f6 100644 --- a/src/Models/Meteor.zig +++ b/src/Models/Meteor.zig @@ -59,18 +59,20 @@ pub const Meteor = struct { var vely: f32 = undefined; var posx: f32 = (Shared.Random.Get().float(f32) * (screenSize.x - 150)) + 150; - while (offscreen) { + const radiusX = if (offscreen) activeRadiusX else 100; + while (true) { const visibleX = posx - player.position.x; - if (visibleX > activeRadiusX or visibleX < -activeRadiusX) { + if (visibleX > radiusX or visibleX < -radiusX) { break; } posx = (Shared.Random.Get().float(f32) * (screenSize.x - 150)) + 150; } var posy: f32 = (Shared.Random.Get().float(f32) * (screenSize.y - 150)) + 150; - while (offscreen) { + const radiusY = if (offscreen) activeRadiusY else 100; + while (true) { const visibleY = posy - player.position.y; - if (visibleY > activeRadiusY or visibleY < -activeRadiusY) { + if (visibleY > radiusY or visibleY < -radiusY) { break; } posy = (Shared.Random.Get().float(f32) * (screenSize.y - 150)) + 150; diff --git a/src/ViewModels/AsteroidsViewModel.zig b/src/ViewModels/AsteroidsViewModel.zig index 7e20b53..bb9dd5e 100644 --- a/src/ViewModels/AsteroidsViewModel.zig +++ b/src/ViewModels/AsteroidsViewModel.zig @@ -100,19 +100,19 @@ pub const AsteroidsViewModel = Shared.View.ViewModel.Create( while (initialMeteorCount < totalStartingMeteors) { switch (Shared.Random.Get().intRangeAtMost(u2, 0, 2)) { 2 => { - bigMeteors[@intCast(bigMeteorsCount)].RandomizePositionAndSpeed(player, screenSize, true); + bigMeteors[@intCast(bigMeteorsCount)].RandomizePositionAndSpeed(player, screenSize, false); bigMeteors[@intCast(bigMeteorsCount)].active = true; initialMeteorCount += 4; bigMeteorsCount += 1; }, 1 => { - mediumMeteors[@intCast(midMeteorsCount)].RandomizePositionAndSpeed(player, screenSize, true); + mediumMeteors[@intCast(midMeteorsCount)].RandomizePositionAndSpeed(player, screenSize, false); mediumMeteors[@intCast(midMeteorsCount)].active = true; initialMeteorCount += 2; midMeteorsCount += 1; }, else => { - smallMeteors[@intCast(smallMeteorsCount)].RandomizePositionAndSpeed(player, screenSize, true); + smallMeteors[@intCast(smallMeteorsCount)].RandomizePositionAndSpeed(player, screenSize, false); smallMeteors[@intCast(smallMeteorsCount)].active = true; initialMeteorCount += 1; smallMeteorsCount += 1;