summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadioactivity <85001747+voidwyrm-2@users.noreply.github.com>2025-07-25 22:00:44 -1000
committerRadioactivity <85001747+voidwyrm-2@users.noreply.github.com>2025-07-25 22:02:27 -1000
commitf1ef44018848632c2ca8168f04970682883cb6bf (patch)
tree7d174033116452d1965940ea4f07e814d0f6a1e7
parentaeb8de234883eb8a4736f847523526b45de364bc (diff)
Fixed Wave.update logic
-rw-r--r--src/main.zig20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main.zig b/src/main.zig
index 1b465f5..0b98455 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -243,15 +243,14 @@ const Wave = struct {
const ai_position = rl.Vector2.init(half_cell, 4 * cell_size + half_cell);
// TODO: post hackathon, optimize this
- for (self.spawn_rules) |*rules| {
- for (0.., rules.bugs) |i, bug| {
- bug.last_spawn += delta_time;
- if (bug.last_spawn >= bug.spawn_interval) {
- bug.last_spawn -= bug.spawn_interval;
- self.bugs.append(Bug.init(i, ai_position)) catch unreachable;
+ for (self.spawn_rules.items) |*rules| {
+ for (0..rules.bugs.len) |i| {
+ rules.bugs[i].last_spawn += delta_time;
+ if (rules.bugs[i].last_spawn >= rules.bugs[i].spawn_interval) {
+ rules.bugs[i].last_spawn -= rules.bugs[i].spawn_interval;
+ self.bugs.append(Bug.init(@enumFromInt(i), ai_position)) catch unreachable;
// TODO: spawn bug
// Should initialize it at the center of AI
- //
}
}
}
@@ -422,7 +421,9 @@ const ScreenBattle = struct {
fn update(self: *ScreenBattle, game: *Game, dt: f32) void {
_ = game;
- _ = dt;
+
+ self.wave.update(dt);
+
self.updateCamera();
}
@@ -475,12 +476,15 @@ const ScreenBattle = struct {
.stack_overflow => game.texture_map.get(.bug_stackoverflow).?,
.infinite_loop => game.texture_map.get(.bug_while).?,
};
+
rl.drawTextureRec(
texture,
.{ .x = bug.animation_state * cell_size, .y = 0, .width = cell_size, .height = cell_size },
.{ .x = bug.position.x - half_cell, .y = bug.position.y - half_cell },
rl.Color.white,
);
+
+ rl.drawTexture(texture, @intFromFloat(bug.position.x), @intFromFloat(bug.position.y), rl.Color.white);
}
}