From e644f05e2315a741b178106fed7f994f74906563 Mon Sep 17 00:00:00 2001 From: Arthur <78031901+Arthur7770@users.noreply.github.com> Date: Mon, 8 Mar 2021 12:06:50 +0100 Subject: [PATCH] Key movement accelaration problem solved --- .../screen/gl3d/GLKeyboardListener.java | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/src/lsystem/screen/gl3d/GLKeyboardListener.java b/src/lsystem/screen/gl3d/GLKeyboardListener.java index 4c25d22..4b0c04d 100644 --- a/src/lsystem/screen/gl3d/GLKeyboardListener.java +++ b/src/lsystem/screen/gl3d/GLKeyboardListener.java @@ -17,40 +17,20 @@ public class GLKeyboardListener implements KeyListener { switch (e.getKeyChar()) { case 'z': - if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){ - canvas.camera[2] -= 0.1f; - canvas.camera[0] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - }else{ - canvas.camera[2] += 0.1f; - canvas.camera[0] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - } + canvas.camera[2] -= 0.1f*Math.cos(Math.toRadians(canvas.camera[3])); + canvas.camera[0] += 0.1f*Math.cos(Math.toRadians(90-canvas.camera[3])); break; case 's': - if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){ - canvas.camera[2] += 0.1f; - canvas.camera[0] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - }else{ - canvas.camera[2] -= 0.1f; - canvas.camera[0] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - } + canvas.camera[2] += 0.1f*Math.cos(Math.toRadians(canvas.camera[3])); + canvas.camera[0] -= 0.1f*Math.cos(Math.toRadians(90-canvas.camera[3])); break; case 'q': - if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){ - canvas.camera[0] -= 0.1f; - canvas.camera[2] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - }else{ - canvas.camera[0] += 0.1f; - canvas.camera[2] -= 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - } + canvas.camera[2] += 0.1f*Math.cos(Math.toRadians(canvas.camera[3]+90)); + canvas.camera[0] += 0.1f*Math.cos(Math.toRadians(180-canvas.camera[3])); break; case 'd': - if(Math.abs(canvas.camera[3]) < 180 || Math.abs(canvas.camera[3])>0 ){ - canvas.camera[0] += 0.1f; - canvas.camera[2] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - }else{ - canvas.camera[0] -= 0.1f; - canvas.camera[2] += 0.1f*Math.tan(Math.toRadians(canvas.camera[3])); - } + canvas.camera[2] -= 0.1f*Math.cos(Math.toRadians(canvas.camera[3]+90)); + canvas.camera[0] -= 0.1f*Math.cos(Math.toRadians(180-canvas.camera[3])); break; case 'a': canvas.camera[3] -= 1;