From 486935299e4b7e097754611d9f8dd40003351ae4 Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Mon, 25 Oct 2021 22:17:35 -0400 Subject: Mouse look! --- src/main.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 781b9a7..6a10921 100644 --- a/src/main.zig +++ b/src/main.zig @@ -103,6 +103,10 @@ pub fn main() !void { window.setFramerateLimit(40); + // TODO: implement this in the SFML wrapper and make a PR + sf.c.sfRenderWindow_setMouseCursorGrabbed(window.ptr, 1); + sf.c.sfRenderWindow_setMouseCursorVisible(window.ptr, 0); + // Load the background skybox, really `skycylinder', and assign it to a // sprite -- it's set to repeating so that it goes on forever. We need to // scale the sprite so that drawing 1/4 of backTextureWidth fills the Screen @@ -153,6 +157,9 @@ pub fn main() !void { if (isKeyPressed(.C)) plyr.height -= 0.1; if (isKeyPressed(.V)) plyr.height += 0.1; + plyr.ang -= @intToFloat(f32, sf.window.mouse.getPosition(window).x) / constants.ScreenWidth - 0.5; + sf.window.mouse.setPosition(.{.x = constants.ScreenWidth / 2, .y = 0}, window); + const rotation = 2.0 * PI / 200.0; if (isKeyPressed(.Left)) plyr.ang += rotation; if (isKeyPressed(.Right)) plyr.ang -= rotation; -- cgit v1.3.1