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;
- if glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS {
+ speed := 7 * dt;
+ if glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS {
speed = 15 * dt;
}
- facing := camera_get_forward(^camera);
+ forward := camera_get_forward(^camera);
+ facing := forward;
+ facing.y = 0;
+ facing = Vector3.norm(facing);
if glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS {
camera.position += facing * speed;
}
}
dir: Vector3i;
- if !world_ray_cast(.{ camera.position, facing }, 40, null, (_, p) => {
+ if !world_ray_cast(.{ camera.position, forward }, 40, null, (_, p) => {
return world_get_block(world, p.x, p.y, p.z) != Block_Empty;
}, ^selected_block, ^dir) {
selected_block = .{0,0,0};
}
if glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS {
+ camera.position.y += 7 * dt;
+ }
+ if glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS {
+ camera.position.y -= 7 * dt;
+ }
+
+ if glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS {
world_set_block(world, selected_block.x, selected_block.y, selected_block.z, Block_Empty);
}
if debug_screen {
ww, wh: i32;
glfwGetWindowSize(window, ^ww, ^wh);
- font_print(font, ~~(ww / 2), ~~(wh / 2), "X");
+ font_print(font, ~~(ww / 2), ~~(wh / 2), ".");
font_print(font, 0, 32, "FPS: {}", game_fps);
font_print(font, 0, 64, "Position: {}", camera.position);