aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authortslil clingman <>2021-10-25 22:17:35 -0400
committertslil clingman <>2021-10-25 22:17:35 -0400
commit486935299e4b7e097754611d9f8dd40003351ae4 (patch)
treea87b9d02639ec87c3f9e83d77addb95a8c9e412e /src/main.zig
parent681d7f8a489b4dbfa0712351c1d993d2df47469c (diff)
Mouse look!
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig7
1 files changed, 7 insertions, 0 deletions
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;