Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / spaceship.js
diff options
context:
space:
mode:
1 files changed, 5 insertions, 2 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/spaceship.js7
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);