3D Gravity for @Valoeghese

pull/12/head
Caroline Bell 2020-02-25 14:42:28 -08:00
parent d3c5da572c
commit da49f4e1de
5 changed files with 8 additions and 6 deletions

View File

@ -30,7 +30,7 @@ public class Litecraft extends Game
{ {
Constants.movementSpeed = 0.00005f; Constants.movementSpeed = 0.00005f;
Constants.turnSpeed = 0.00006f; Constants.turnSpeed = 0.00006f;
Constants.gravity = -0.0000000005f; Constants.gravity = new org.joml.Vector3f(0, -0.0000000005f, 0);
Constants.jumpPower = 0.00005f; Constants.jumpPower = 0.00005f;
Window.create(1200, 800, "LiteCraft", 60); Window.create(1200, 800, "LiteCraft", 60);
GingerUtils.init(); GingerUtils.init();
@ -85,7 +85,7 @@ public class Litecraft extends Game
} }
oldWindowWidth = Window.width; oldWindowWidth = Window.width;
oldWindowHeight = Window.height; oldWindowHeight = Window.height;
ginger3D.masterRenderer.renderShadowMap(data.entities, data.lights.get(0)); ginger3D.gingerRegister.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
if (isInWorld) if (isInWorld)
{ ginger3D.renderWithoutTerrain(this, world); } { ginger3D.renderWithoutTerrain(this, world); }
ginger3D.renderOverlays(this); ginger3D.renderOverlays(this);

View File

@ -30,7 +30,7 @@ public class Litecraft extends Game
{ {
Constants.movementSpeed = 0.00005f; Constants.movementSpeed = 0.00005f;
Constants.turnSpeed = 0.00006f; Constants.turnSpeed = 0.00006f;
Constants.gravity = -0.0000000005f; Constants.gravity = new org.joml.Vector3f(0,-0.0000000005f,0);
Constants.jumpPower = 0.00005f; Constants.jumpPower = 0.00005f;
Window.create(1200, 800, "LiteCraft", 60); Window.create(1200, 800, "LiteCraft", 60);
GingerUtils.init(); GingerUtils.init();

View File

@ -68,7 +68,7 @@ public class Player extends RenderObject
if (t != null) if (t != null)
{ terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z); } { terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z); }
super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime())), 0); super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime())), 0);
upwardsSpeed += Constants.gravity * Window.getTime(); upwardsSpeed += Constants.gravity.y() * Window.getTime();
if (super.getPosition().y < terrainHeight) if (super.getPosition().y < terrainHeight)
{ {
isInAir = false; isInAir = false;

View File

@ -69,7 +69,7 @@ public class Particle
public boolean update(Camera camera) public boolean update(Camera camera)
{ {
float time = (float) Window.getTime() / 1000000; float time = (float) Window.getTime() / 1000000;
velocity.y += Constants.gravity * gravityEffect * time; velocity.y += Constants.gravity.y() * gravityEffect * time;
Vector3f change = new Vector3f(velocity); Vector3f change = new Vector3f(velocity);
change.scale(time); change.scale(time);
Vector3f.add(change, position, position); Vector3f.add(change, position, position);

View File

@ -1,9 +1,11 @@
package com.github.hydos.ginger.main.settings; package com.github.hydos.ginger.main.settings;
import org.joml.Vector3f;
public class Constants public class Constants
{ {
//player variables //player variables
public static float gravity = 0; public static Vector3f gravity = new Vector3f(0,0,0);
public static float jumpPower = 0; public static float jumpPower = 0;
public static float turnSpeed = 0; public static float turnSpeed = 0;
public static double movementSpeed = 0; public static double movementSpeed = 0;