From 8608f2c0e0d02e58df9280eab03a6b7a96acd5f1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 27 Aug 2023 14:58:32 +0300 Subject: [WGL/P] Added a proper level management system, added more options to the menu --- Year 2/Computer Graphics with WebGL/Project/spaceship.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Year 2/Computer Graphics with WebGL/Project/spaceship.js') diff --git a/Year 2/Computer Graphics with WebGL/Project/spaceship.js b/Year 2/Computer Graphics with WebGL/Project/spaceship.js index cb3b548..654b451 100644 --- a/Year 2/Computer Graphics with WebGL/Project/spaceship.js +++ b/Year 2/Computer Graphics with WebGL/Project/spaceship.js @@ -112,11 +112,14 @@ document.addEventListener('keyup', (event) => { /* * Mouse movement */ + +var onlyHorizontal = false; +var onlyVertical = false; function updateLookingDirection(e) { if (isPaused) return; - var vertical = (e.movementY / canvas.offsetHeight) * ROTATION_SPEED; - var horizontal = (-e.movementX / canvas.offsetWidth) * ROTATION_SPEED; + var vertical = (1-onlyHorizontal) * (e.movementY / canvas.offsetHeight) * ROTATION_SPEED; + var horizontal = (1-onlyVertical) * (-e.movementX / canvas.offsetWidth) * ROTATION_SPEED; forward.addAngles(vertical, horizontal); up.addAngles(vertical, horizontal); -- cgit v1.3.1-26-gb76a