From f6a1b400454a63860fe1a2af3aea4410d29a83be Mon Sep 17 00:00:00 2001 From: Radioactivity <85001747+voidwyrm-2@users.noreply.github.com> Date: Sun, 27 Jul 2025 16:51:32 -1000 Subject: Changes - Removed superflous empty C library - Rewrote build script - Added Konami code --- src/main.zig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 1b5cbf2..e8e8201 100644 --- a/src/main.zig +++ b/src/main.zig @@ -20,6 +20,20 @@ const edit = debug and false; var screen_width: i32 = 1280; var screen_height: i32 = 720; +const konami_code = [_]rl.KeyboardKey{ + .up, + .up, + .down, + .down, + .left, + .right, + .left, + .right, + .b, + .a, + .enter, +}; + // TODO: ideas for the future (after hackathon) // "Heat system" (shooting lazers increases heat, heat decreases over time, if heat is too high, CPU throttles) // "Cooling system" some way to have CPUs that are more resistant to heat @@ -73,6 +87,17 @@ fn getMousePos(camera: *const rl.Camera2D) rl.Vector2 { }; } +fn readCode(counter: *u8, seq: []const rl.KeyboardKey) bool { + if (counter.* >= seq.len) { + counter.* = 0; + return true; + } else if (rl.isKeyPressed(seq[@as(usize, counter.*)])) { + counter.* += 1; + } + + return false; +} + fn textureButtonScaled(game: *Game, camera: *const rl.Camera2D, texture: rl.Texture2D, pos: rl.Vector2, rotation: f32, scale: f32) bool { const msp = getMousePos(camera); @@ -1433,6 +1458,7 @@ const ScreenBattle = struct { skipped: bool = false, completion_time: f32 = 0, popup: bool = false, + konami_counter: u8 = 0, const max_ram = 100; const initial_cpu_transistor_cost = 50; @@ -1539,6 +1565,12 @@ const ScreenBattle = struct { f.writeByte('\n') catch unreachable; unreachable; } + + var mut_konami_code = konami_code; + + if (readCode(&self.konami_counter, &mut_konami_code)) { + self.transistors += 10000; + } } fn updateCpuAndBugs(self: *ScreenBattle, game: *Game, dt: f32) void { -- cgit v1.3.1