summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-07-26 11:49:20 +0300
committerKyren223 <Kyren223@proton.me>2025-07-26 11:49:20 +0300
commitc4b036533d65eb1c76c5b75e0364b816eac7f796 (patch)
treed290bdc3f2d81a4f79fcbc57deb9a8cbed20a9ab
parentd0e629a6db08dc84e7bd11940d276616ab085f1c (diff)
Fixed animation issue for while bug (I think?)
-rw-r--r--src/main.zig13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig
index f419dfd..8d211b9 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -62,7 +62,6 @@ const Bug = struct {
target: rl.Vector2, // Center of next cell
animation_time: f32 = 0,
animation_state: f32 = 0,
- const animation_switch_threshold = 0.3; // seconds
pub fn init(kind: BugKind, position: rl.Vector2) Bug {
return Bug{
@@ -76,7 +75,7 @@ const Bug = struct {
pub fn update(self: *Bug, delta_time: f32, wave: *Wave) void {
self.animation_time += delta_time;
- if (self.animation_time > animation_switch_threshold) {
+ if (self.animation_time > animationSwitchThreshold(self.kind)) {
self.animation_time = 0;
self.animation_state = @mod((self.animation_state + 1), animationCount(self.kind));
}
@@ -168,6 +167,14 @@ const Bug = struct {
.infinite_loop => return 6,
};
}
+
+ fn animationSwitchThreshold(kind: BugKind) f32 {
+ return switch (kind) {
+ .nullptr_deref => return 0.3,
+ .stack_overflow => return 0.3,
+ .infinite_loop => return 0.05,
+ };
+ }
};
const Condition = union(enum) {
@@ -252,9 +259,9 @@ const Wave = struct {
.from_time_s = 0,
.to_time_s = 10,
.bugs = .{
- .{ .spawn_interval = 3 },
.{ .spawn_interval = 0 },
.{ .spawn_interval = 0 },
+ .{ .spawn_interval = 3 },
},
}) catch unreachable;
// spawn_rules.append(.{