removed flying added double jump :)

This commit is contained in:
Will_Allen 2026-07-07 14:07:22 +01:00
parent 42fc70100d
commit f2174e4364
2 changed files with 1048 additions and 948 deletions

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,8 @@ import net.halbear.Terrain4J.EngineCore.Input.KeyboardInput;
import net.halbear.Terrain4J.EngineCore.Input.MouseListener;
import net.halbear.Terrain4J.EngineCore.Logic.EngineConfig;
import net.halbear.Terrain4J.EngineCore.Logic.EngineInstance;
import net.halbear.Terrain4J.EngineCore.Logic.Physics.RigidBody.RigidBody;
import net.halbear.Terrain4J.EngineCore.Logic.Physics.RigidBody.RigidPhysicsController;
import net.halbear.Terrain4J.EngineCore.Logic.Rendering.SkyBox;
import net.halbear.Terrain4J.EngineCore.Main.AudioInstance;
import net.halbear.Terrain4J.EngineCore.Main.GameCore;
@ -47,6 +49,8 @@ public class Scene implements IScene {
private SkyBox skyBox;
private Map<String, AudioInstance> audioInstances;
private DynamicTerrainMesh terrainMesh;
private int Jumps = 0;
private final int MaxJumps = 2;
public List<String> ActiveGUIs = new ArrayList<>();
public Map<String, GUIOverlay> GUIReg = new HashMap<>();
@ -71,7 +75,9 @@ public class Scene implements IScene {
terrainMesh = new DynamicTerrainMesh(PrimaryRuntime.GetRenderThread().GetRenderer().GetVulkanContext().GetDevice(), Heights, Width, Height);
}
public SkyBox GetSkyBox(){return skyBox;}
public SkyBox GetSkyBox() {
return skyBox;
}
public Scene(Window window) {
// CreateTerrainMesh();
@ -89,7 +95,9 @@ public class Scene implements IScene {
ActiveGUIs.add("PerformanceOverlay");
}
public ISceneLightingManager GetLightingManager(){return lightingManager;}
public ISceneLightingManager GetLightingManager() {
return lightingManager;
}
public void CameraTick(long FrameDiffNanoSeconds) {
float FrameTimeMS = FrameDiffNanoSeconds / 1000000.0f;
@ -133,25 +141,43 @@ public class Scene implements IScene {
}
}
public Map<String, CameraFrame> GetCameraFrameReg(){return CameraFrames;}
public CameraFrame GetCameraFrame(String Name){return CameraFrames.get(Name);}
public Map<String, CameraFrame> GetCameraFrameReg() {
return CameraFrames;
}
public CameraFrame GetCameraFrame(String Name) {
return CameraFrames.get(Name);
}
public Scene AddCameraFrame(String Name, CameraFrame frame) {
CameraFrames.put(Name, frame);
return this;
}
public void StartCameraTrack(String StartFrame, String EndFrame, int TickAmount) {
ActiveCameraFrame = StartFrame;
CurrentTransitionTick = 0;
TotalTransitionTicks = TickAmount;
SetCameraFrame = EndFrame;
}
public void SetActiveCameraFrame(String frameName){SetCameraFrame = frameName;}
public String GetActiveCameraFrame(){return ActiveCameraFrame;}
public Camera GetCamera(){return camera;}
public void SetActiveCameraFrame(String frameName) {
SetCameraFrame = frameName;
}
public String GetActiveCameraFrame() {
return ActiveCameraFrame;
}
public Camera GetCamera() {
return camera;
}
public void AddActor(Actor NewActor) {
Actors.put(NewActor.GetID(), NewActor);
ActiveActors.add(NewActor.GetID());
}
public List<Actor> GetActors() {
List<Actor> actors = new ArrayList<>();
for (int i = 0; i < ActiveActors.size(); i++) {
@ -159,9 +185,18 @@ public class Scene implements IScene {
}
return actors;
}
public Project3D GetProjection(){return Projection;}
public void RemoveAllActors(){Actors.clear();}
public Actor RemoveActor(Actor actor){return Actors.remove(actor.GetID());}
public Project3D GetProjection() {
return Projection;
}
public void RemoveAllActors() {
Actors.clear();
}
public Actor RemoveActor(Actor actor) {
return Actors.remove(actor.GetID());
}
public void SetUpAudio(EngineInstance engineInstance) {
@ -203,26 +238,41 @@ public class Scene implements IScene {
}
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))));
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))));
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))));
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))));
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 (playerActor != null) {
RigidPhysicsController physicsController = (RigidPhysicsController) playerActor.GetPhysicsController();
RigidBody body = RigidBody.RigidBodyRegister.get(physicsController.RigidBodyID);
if (body != null && body.Grounded) {
Jumps = 0;
}
}
if (input.keySinglePress(GLFW_KEY_SPACE)) {
// camera.MoveUp(MovementDist);
if (Jumps < MaxJumps) {
if (playerActor != null) playerActor.Move(new Vector3f(0, 5f, 0));
Jumps++;
}
}
if (input.keyPressed(GLFW_KEY_LEFT_SHIFT)) {
if (playerActor == null) camera.MoveDown(MovementDist);