diff --git a/src/lsystem/screen/listener/JoglMouseListener.java b/src/lsystem/screen/listener/JoglMouseListener.java index c9790bd..90a6d3d 100644 --- a/src/lsystem/screen/listener/JoglMouseListener.java +++ b/src/lsystem/screen/listener/JoglMouseListener.java @@ -53,7 +53,7 @@ public class JoglMouseListener implements MouseListener, MouseMotionListener, Mo if(origine != null) { double xDiff = origine.getX() - e.getPoint().getX(); double yDiff = origine.getY() - e.getPoint().getY(); - /* if(button == 2) { + /* if(button == 1) { canvas.camera[0] += Math.cos(canvas.camera[3]) * xDiff * 0.01; canvas.camera[1] += Math.cos(canvas.camera[4]) * yDiff * 0.01; canvas.camera[2] += Math.sin(canvas.camera[3]) * xDiff * 0.01; diff --git a/src/lsystem/screen/listener/KeyboardListener.java b/src/lsystem/screen/listener/KeyboardListener.java index dcd8d26..07ebda9 100644 --- a/src/lsystem/screen/listener/KeyboardListener.java +++ b/src/lsystem/screen/listener/KeyboardListener.java @@ -19,16 +19,40 @@ public class KeyboardListener implements KeyListener { switch (e.getKeyChar()) { case 'z': - canvas.camera[2] -= 0.1f; + 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])); + } break; case 's': - canvas.camera[2] += 0.1f; + 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])); + } break; case 'q': - canvas.camera[0] -= 0.1f; + 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])); + } break; case 'd': - canvas.camera[0] += 0.1f; + 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])); + } break; case 'a': canvas.camera[3] -= 1;