From ced33b055f97e6d2882c80f4d7499ff138e77725 Mon Sep 17 00:00:00 2001 From: Radioactivity <85001747+voidwyrm-2@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:27:58 -1000 Subject: Attempting mouse screen to world coord translation --- src/main.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index fff3c4d..3aa5c1f 100644 --- a/src/main.zig +++ b/src/main.zig @@ -372,6 +372,12 @@ const Wave = struct { } return self.map[y][x]; } + + fn set(self: *Wave, x: usize, y: usize, cell: Cell) void { + if (x < cells_width and y < cells_height) { + self.map[y][x] = cell; + } + } }; const TextureKind = enum { @@ -514,6 +520,13 @@ const ScreenMainMenu = struct { rl.beginMode2D(self.camera); defer rl.endMode2D(); + const msp = rl.getMousePosition(); + + const x = msp.x / (cells_width * cells_height); + const y = msp.y / (cells_width * cells_height); + + rl.drawRectangleRec(rl.Rectangle.init(x, y, 100, 100), rl.Color.white); + // what are we actually calling this game? rl.drawTextEx(game.font_title, "Bug Defenders", rl.Vector2.init(495, 160), 40, 4, rl.Color.white); -- cgit v1.3.1