Key movement accelaration problem solved

This commit is contained in:
Arthur 2021-03-08 12:06:50 +01:00
parent bd48d32080
commit e644f05e23

View File

@ -17,40 +17,20 @@ public class GLKeyboardListener implements KeyListener {
switch (e.getKeyChar()) { switch (e.getKeyChar()) {
case 'z': case 'z':
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){ canvas.camera[2] -= 0.1f*Math.cos(Math.toRadians(canvas.camera[3]));
canvas.camera[2] -= 0.1f; canvas.camera[0] += 0.1f*Math.cos(Math.toRadians(90-canvas.camera[3]));
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; break;
case 's': case 's':
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){ canvas.camera[2] += 0.1f*Math.cos(Math.toRadians(canvas.camera[3]));
canvas.camera[2] += 0.1f; canvas.camera[0] -= 0.1f*Math.cos(Math.toRadians(90-canvas.camera[3]));
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; break;
case 'q': case 'q':
if(Math.abs(canvas.camera[3]) < 90 || Math.abs(canvas.camera[3])>270 ){ canvas.camera[2] += 0.1f*Math.cos(Math.toRadians(canvas.camera[3]+90));
canvas.camera[0] -= 0.1f; canvas.camera[0] += 0.1f*Math.cos(Math.toRadians(180-canvas.camera[3]));
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; break;
case 'd': case 'd':
if(Math.abs(canvas.camera[3]) < 180 || Math.abs(canvas.camera[3])>0 ){ canvas.camera[2] -= 0.1f*Math.cos(Math.toRadians(canvas.camera[3]+90));
canvas.camera[0] += 0.1f; canvas.camera[0] -= 0.1f*Math.cos(Math.toRadians(180-canvas.camera[3]));
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; break;
case 'a': case 'a':
canvas.camera[3] -= 1; canvas.camera[3] -= 1;