Skip to content

Commit b25dc02

Browse files
nearly perfect!
1 parent a4801b5 commit b25dc02

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/terrain generation.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,21 @@ def get_height_at_origin(vertices, grid_size):
235235

236236
# Mouse look controls
237237
x, y = pygame.mouse.get_pos()
238-
x = time.time() * 250
239238
dx, dy = x - last_x, last_y - y
240-
last_x, last_y = x, y
241239

242240
camera_pos[0] = 0
243241
camera_pos[1] = camera_height + 5#1
244242
camera_pos[2] = 0
245243

246-
244+
# Sensitivity adjustment
247245
sensitivity = 0.1
248246
dx *= sensitivity
249247
dy *= sensitivity
250248

251249
yaw += dx
252250
pitch += dy
251+
252+
# Clamp the pitch to prevent flipping
253253
if pitch > 89.0:
254254
pitch = 89.0
255255
if pitch < -89.0:
@@ -263,6 +263,10 @@ def get_height_at_origin(vertices, grid_size):
263263
])
264264
camera_front = front / np.linalg.norm(front)
265265

266+
# Reset mouse to the center of the screen
267+
pygame.mouse.set_pos(WIDTH // 2, HEIGHT // 2)
268+
last_x, last_y = WIDTH // 2, HEIGHT // 2
269+
266270
# Compute view and projection matrices
267271
view = Matrix44.look_at(camera_pos, camera_pos + camera_front, camera_up)
268272
projection = Matrix44.perspective_projection(90.0, WIDTH / HEIGHT, 0.1, 1000000.0)

0 commit comments

Comments
 (0)