Fixed movement Input
This commit is contained in:
parent
8a92f99474
commit
42fc70100d
3 changed files with 39 additions and 62 deletions
|
|
@ -284,61 +284,9 @@ public class GameCore implements GameLogic {
|
||||||
public void Input(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
public void Input(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
||||||
IScene scene = engineInstance.scene();
|
IScene scene = engineInstance.scene();
|
||||||
Window window = engineInstance.window();
|
Window window = engineInstance.window();
|
||||||
|
|
||||||
KeyboardInput input = window.getKeyboardInput();
|
|
||||||
float MovementDist = (float)(FrameDiffNanoSeconds / 1000000L) * MOVEMENT_SPEED;
|
|
||||||
Camera camera = scene.GetCamera();
|
|
||||||
PlayerActor playerActor = (PlayerActor) Actor.Actors.get(PlayerActorID);
|
PlayerActor playerActor = (PlayerActor) Actor.Actors.get(PlayerActorID);
|
||||||
if(playerActor!= null)camera = Camera.GetCamera(playerActor.AttachedCameraID);
|
scene.Input(engineInstance,FrameDiffNanoSeconds, playerActor, MOVEMENT_SPEED,this);
|
||||||
if(input.keyPressed(GLFW_KEY_ENTER)) {
|
|
||||||
SpawnNewActor(engineInstance, new Vector3f( (float)(5 * Math.random()),20 + (float)(10 * Math.random()), (float)(5 * Math.random())),new Vector3f(-1f + (float)(2 * Math.random()),-1f + (float)(2 * Math.random()),-1f + (float)(2 * Math.random())),new Vector3f((float)Math.random(),(float)Math.random(),(float)Math.random()));
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_1)) {
|
|
||||||
Gimbal.universalType = Gimbal.GimbalType.Move;
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_2)) {
|
|
||||||
Gimbal.universalType = Gimbal.GimbalType.Resize;
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_3)) {
|
|
||||||
Gimbal.universalType = Gimbal.GimbalType.Rotate;
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_TAB)){
|
|
||||||
for(int i = 0; i < ActorEditorComponents.size(); i++){
|
|
||||||
ActorEditorComponents.get(i).UpdateAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(input.keySinglePress(GLFW_KEY_F2)) {
|
|
||||||
EngineConfig.getInstance().SetRenderCollisionMesh(!EngineConfig.getInstance().RenderCollisionMeshes());
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_W)){
|
|
||||||
if(playerActor == null)camera.MoveForward(MovementDist);
|
|
||||||
else playerActor.Move(new Vector3f(MovementDist* (float)Math.sin((camera.GetRotation().y)),0,-MovementDist* (float)Math.cos((camera.GetRotation().y))));
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_S)){
|
|
||||||
if(playerActor == null)camera.MoveBackward(MovementDist);
|
|
||||||
else playerActor.Move(new Vector3f(-MovementDist* (float)Math.sin((camera.GetRotation().y)),0,MovementDist * (float)Math.cos((camera.GetRotation().y))));
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_A)){
|
|
||||||
if(playerActor == null) camera.MoveLeft(MovementDist);
|
|
||||||
else playerActor.Move(new Vector3f(-MovementDist * (float)Math.cos((camera.GetRotation().y)),0,-MovementDist * (float)Math.sin((camera.GetRotation().y))));
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_D)){
|
|
||||||
if(playerActor == null)camera.MoveRight(MovementDist);
|
|
||||||
else playerActor.Move(new Vector3f(MovementDist * (float)Math.cos((camera.GetRotation().y)),0,MovementDist * (float)Math.sin((camera.GetRotation().y))));
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_SPACE)){
|
|
||||||
if(playerActor == null)camera.MoveUp(MovementDist);
|
|
||||||
}
|
|
||||||
if(input.keySinglePress(GLFW_KEY_SPACE)){
|
|
||||||
// camera.MoveUp(MovementDist);
|
|
||||||
if(playerActor != null)playerActor.Move(new Vector3f(0,5f,0));
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_LEFT_SHIFT)){
|
|
||||||
if(playerActor == null)camera.MoveDown(MovementDist);
|
|
||||||
}
|
|
||||||
if(input.keyPressed(GLFW_KEY_LEFT_CONTROL)){
|
|
||||||
camera.Sprint(true);
|
|
||||||
} else camera.Sprint(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean HandleGui(EngineInstance engineInstance, long frameTimeNS){
|
private boolean HandleGui(EngineInstance engineInstance, long frameTimeNS){
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public interface IScene {
|
||||||
public Project3D GetProjection();
|
public Project3D GetProjection();
|
||||||
public void RemoveAllActors();
|
public void RemoveAllActors();
|
||||||
public Actor RemoveActor(Actor actor);
|
public Actor RemoveActor(Actor actor);
|
||||||
public void Input(EngineInstance engineInstance, long FrameDiffNanoSeconds);
|
public void Input(EngineInstance engineInstance, long FrameDiffNanoSeconds, PlayerActor playerActor, float MOVEMENT_SPEED,GameCore parent);
|
||||||
public void Update(EngineInstance engineInstance, long FrameDiffNanoSeconds);
|
public void Update(EngineInstance engineInstance, long FrameDiffNanoSeconds);
|
||||||
public void UpdateFastThread(EngineInstance engineInstance, long FrameDiffNanoSeconds);
|
public void UpdateFastThread(EngineInstance engineInstance, long FrameDiffNanoSeconds);
|
||||||
public void SecondUpdate(EngineInstance engineInstance);
|
public void SecondUpdate(EngineInstance engineInstance);
|
||||||
|
|
|
||||||
|
|
@ -170,33 +170,62 @@ public class Scene implements IScene {
|
||||||
public int GUI_MODE = 0;
|
public int GUI_MODE = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Input(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
public void Input(EngineInstance engineInstance, long FrameDiffNanoSeconds,PlayerActor playerActor, float MOVEMENT_SPEED, GameCore parent) {
|
||||||
IScene scene = engineInstance.scene();
|
IScene scene = engineInstance.scene();
|
||||||
Window window = engineInstance.window();
|
Window window = engineInstance.window();
|
||||||
|
|
||||||
KeyboardInput input = window.getKeyboardInput();
|
KeyboardInput input = window.getKeyboardInput();
|
||||||
float MovementDist = (float)(FrameDiffNanoSeconds / 1000000L) * MOVEMENT_SPEED;
|
float MovementDist = (float)(FrameDiffNanoSeconds / 1000000L) * MOVEMENT_SPEED;
|
||||||
Camera camera = scene.GetCamera();
|
Camera camera = scene.GetCamera();
|
||||||
|
if(playerActor!= null)camera = Camera.GetCamera(playerActor.AttachedCameraID);
|
||||||
if(input.keySinglePress(GLFW_KEY_F3)){
|
if(input.keySinglePress(GLFW_KEY_F3)){
|
||||||
GUI_MODE = (GUI_MODE + 1) % 2;
|
GUI_MODE = (GUI_MODE + 1) % 2;
|
||||||
}
|
}
|
||||||
|
if(input.keyPressed(GLFW_KEY_ENTER)) {
|
||||||
|
parent.SpawnNewActor(engineInstance, new Vector3f( (float)(5 * Math.random()),20 + (float)(10 * Math.random()), (float)(5 * Math.random())),new Vector3f(-1f + (float)(2 * Math.random()),-1f + (float)(2 * Math.random()),-1f + (float)(2 * Math.random())),new Vector3f((float)Math.random(),(float)Math.random(),(float)Math.random()));
|
||||||
|
}
|
||||||
|
if(input.keyPressed(GLFW_KEY_1)) {
|
||||||
|
Gimbal.universalType = Gimbal.GimbalType.Move;
|
||||||
|
}
|
||||||
|
if(input.keyPressed(GLFW_KEY_2)) {
|
||||||
|
Gimbal.universalType = Gimbal.GimbalType.Resize;
|
||||||
|
}
|
||||||
|
if(input.keyPressed(GLFW_KEY_3)) {
|
||||||
|
Gimbal.universalType = Gimbal.GimbalType.Rotate;
|
||||||
|
}
|
||||||
|
if(input.keyPressed(GLFW_KEY_TAB)){
|
||||||
|
for(int i = 0; i < parent.ActorEditorComponents.size(); i++){
|
||||||
|
parent.ActorEditorComponents.get(i).UpdateAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(input.keySinglePress(GLFW_KEY_F2)) {
|
||||||
|
EngineConfig.getInstance().SetRenderCollisionMesh(!EngineConfig.getInstance().RenderCollisionMeshes());
|
||||||
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_W)){
|
if(input.keyPressed(GLFW_KEY_W)){
|
||||||
camera.MoveForward(MovementDist);
|
if(playerActor == null)camera.MoveForward(MovementDist);
|
||||||
|
else playerActor.Move(new Vector3f(MovementDist* (float)Math.sin((camera.GetRotation().y)),0,-MovementDist* (float)Math.cos((camera.GetRotation().y))));
|
||||||
}
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_S)){
|
if(input.keyPressed(GLFW_KEY_S)){
|
||||||
camera.MoveBackward(MovementDist);
|
if(playerActor == null)camera.MoveBackward(MovementDist);
|
||||||
|
else playerActor.Move(new Vector3f(-MovementDist* (float)Math.sin((camera.GetRotation().y)),0,MovementDist * (float)Math.cos((camera.GetRotation().y))));
|
||||||
}
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_A)){
|
if(input.keyPressed(GLFW_KEY_A)){
|
||||||
camera.MoveLeft(MovementDist);
|
if(playerActor == null) camera.MoveLeft(MovementDist);
|
||||||
|
else playerActor.Move(new Vector3f(-MovementDist * (float)Math.cos((camera.GetRotation().y)),0,-MovementDist * (float)Math.sin((camera.GetRotation().y))));
|
||||||
}
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_D)){
|
if(input.keyPressed(GLFW_KEY_D)){
|
||||||
camera.MoveRight(MovementDist);
|
if(playerActor == null)camera.MoveRight(MovementDist);
|
||||||
|
else playerActor.Move(new Vector3f(MovementDist * (float)Math.cos((camera.GetRotation().y)),0,MovementDist * (float)Math.sin((camera.GetRotation().y))));
|
||||||
}
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_SPACE)){
|
if(input.keyPressed(GLFW_KEY_SPACE)){
|
||||||
camera.MoveUp(MovementDist);
|
if(playerActor == null)camera.MoveUp(MovementDist);
|
||||||
|
}
|
||||||
|
if(input.keySinglePress(GLFW_KEY_SPACE)){
|
||||||
|
// camera.MoveUp(MovementDist);
|
||||||
|
if(playerActor != null)playerActor.Move(new Vector3f(0,5f,0));
|
||||||
}
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_LEFT_SHIFT)){
|
if(input.keyPressed(GLFW_KEY_LEFT_SHIFT)){
|
||||||
camera.MoveDown(MovementDist);
|
if(playerActor == null)camera.MoveDown(MovementDist);
|
||||||
}
|
}
|
||||||
if(input.keyPressed(GLFW_KEY_LEFT_CONTROL)){
|
if(input.keyPressed(GLFW_KEY_LEFT_CONTROL)){
|
||||||
camera.Sprint(true);
|
camera.Sprint(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue