aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.zig8
-rw-r--r--src/particle.zig25
2 files changed, 13 insertions, 20 deletions
diff --git a/src/config.zig b/src/config.zig
index 06d60bb..98eab62 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -1,10 +1,10 @@
const rl = @import("raylib");
const part = @import("particle.zig");
-pub const screenWidth = 2560;
-pub const screenHeight = 1440;
-pub const particleMax = 4000;
-pub const initialParticles = 3000;
+pub const screenWidth = 2880;
+pub const screenHeight = 1620;
+pub const particleMax = 5000;
+pub const initialParticles = 2000;
pub const colorAmnt = colors.len;
pub var particleCount: i32 = initialParticles;
diff --git a/src/particle.zig b/src/particle.zig
index 7b16182..5c97ee5 100644
--- a/src/particle.zig
+++ b/src/particle.zig
@@ -6,9 +6,9 @@ const rl = @import("raylib");
pub fn initParticles(allocator: std.mem.Allocator, amnt: u32) !std.MultiArrayList(particle) {
var particles = std.MultiArrayList(particle){};
try particles.setCapacity(allocator, cfg.particleMax);
- for (0..amnt) |_| {
+ for (0..amnt) |_|
try particles.append(allocator, createParticle());
- }
+
return particles;
}
@@ -25,29 +25,22 @@ pub fn updateVelocities(particles: std.MultiArrayList(particle), rules: [cfg.col
if (i == j) continue;
var check2x = x - cfg.screenWidth;
var check2y = y - cfg.screenWidth;
- if (x < cfg.screenWidth / 2)
- check2x = x + cfg.screenWidth;
- if (y < cfg.screenHeight / 2)
- check2y = y + cfg.screenHeight;
+ if (x < cfg.screenWidth / 2) check2x = x + cfg.screenWidth;
+ if (y < cfg.screenHeight / 2) check2y = y + cfg.screenHeight;
var rx: f32 = @floatFromInt(x - x2);
var ry: f32 = @floatFromInt(y - y2);
const check2rx: f32 = @floatFromInt(check2x - x2);
const check2ry: f32 = @floatFromInt(check2y - y2);
- const r1 = @sqrt(rx * rx + ry * ry);
- const r2 = @sqrt(rx * rx + check2ry * check2ry);
- const r3 = @sqrt(check2rx * check2rx + check2ry * check2ry);
- const r4 = @sqrt(check2rx * check2rx + ry * ry);
-
- var r = @min(@min(r1, r2), @min(r3, r4));
-
if (@abs(rx) > @abs(check2rx)) rx = check2rx;
if (@abs(ry) > @abs(check2ry)) ry = check2ry;
- if (r == 0) {
- r = 0.0001;
- }
+ if (rx > cfg.radius or ry > cfg.radius) continue;
+
+ var r = @sqrt(rx * rx + ry * ry);
+
+ if (r == 0) r = 0.0001;
if (r > 0 and r < cfg.radius) {
const f = force(r, rules[colorList[i]][colorList[j]]);
forceX = forceX + rx / r * f;