From: Brendan Hansen Date: Tue, 21 Dec 2021 16:11:09 +0000 (-0600) Subject: added toggle to debug screen X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=68af9a840827c72ec02f2003be26a7e5f4ad7c16;p=voxel-shooter.git added toggle to debug screen --- diff --git a/src/main.onyx b/src/main.onyx index 747e2c2..2d08686 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -121,6 +121,8 @@ update :: (dt: f32) { camera.y_rot += ~~(last_mouse_x - mx) / 400.0f; camera.x_rot += ~~(my - last_mouse_y) / 400.0f; + while camera.y_rot >= 2 * math.PI do camera.y_rot -= 2 * math.PI; + while camera.y_rot < 0 do camera.y_rot += 2 * math.PI; camera.x_rot = math.clamp(camera.x_rot, -math.PI / 2 + 0.1, math.PI / 2 - 0.1); speed := 5 * dt; @@ -142,9 +144,21 @@ update :: (dt: f32) { camera.position -= Vector3.norm(Vector3.cross(facing, .{0,1,0})) * speed; } + + + { + #persist last_debug_key := 0; + debug_key := glfwGetKey(window, GLFW_KEY_F7); + if debug_key == GLFW_RELEASE && last_debug_key == GLFW_PRESS { + debug_screen = !debug_screen; + } + last_debug_key = debug_key; + } + update_world_matrix(); } +debug_screen := true; game_fps: i32; draw :: () { @@ -154,7 +168,11 @@ draw :: () { shader_use(world_shader); world_draw(world); - font_print(font, 0, 32, "FPS: {}", game_fps); + if debug_screen { + font_print(font, 0, 32, "FPS: {}", game_fps); + font_print(font, 0, 64, "Position: {}", camera.position); + font_print(font, 0, 96, "Facing: {}", camera.y_rot * 180 / math.PI); + } glfwSwapBuffers(window); }