diff options
| author | Radioactivity <85001747+voidwyrm-2@users.noreply.github.com> | 2025-07-26 08:30:31 -1000 |
|---|---|---|
| committer | Radioactivity <85001747+voidwyrm-2@users.noreply.github.com> | 2025-07-26 08:30:31 -1000 |
| commit | 8288d362379fad27aea7c2e2ac4c478dd190360c (patch) | |
| tree | 6af4c23241e0bc0f430b08688bc91a26105137f7 | |
| parent | db73367aed7d9cbb4f6e7dad1ba7803a0302fcf6 (diff) | |
Fixed camera scaling issues and mouse position issues on Mac
| -rw-r--r-- | src/main.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig index a636067..519f8dc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -26,9 +26,9 @@ pub fn main() anyerror!void { // Initialization //-------------------------------------------------------------------------------------- + rl.setConfigFlags(.{ .window_resizable = false, .window_highdpi = true }); rl.initWindow(screen_width, screen_height, "Hackathon"); defer rl.closeWindow(); // Close window and OpenGL context - rl.setWindowState(.{ .window_resizable = false }); rl.initAudioDevice(); defer rl.closeAudioDevice(); @@ -771,8 +771,10 @@ const ScreenBattle = struct { _ = dt; const msp = rl.getMousePosition().scale(1 / self.camera.zoom); - const mx: usize = @intFromFloat(msp.x / cell_size); - const my: usize = @intFromFloat(msp.y / cell_size); + + // the mouse position can go into the negatives on MacOS, so we need to clamp it + const mx: usize = @intFromFloat(@max(msp.x / cell_size, 0)); + const my: usize = @intFromFloat(@max(msp.y / cell_size, 0)); if (rl.isMouseButtonPressed(rl.MouseButton.left)) { if (self.wave.get(mx, my) == .lane and edit) { |
