Fix bug causing falling through blocks.

origin
Joshua Sigona 3 years ago
parent decc6535b7
commit c0e7b06055
  1. 2
      src/sig/Panel.java
  2. 7
      src/sig/SigRenderer.java

@ -380,7 +380,7 @@ public class Panel extends JPanel implements Runnable {
triPreTransform.copyExtraDataTo(triTransformed); triPreTransform.copyExtraDataTo(triTransformed);
if (t.b!=null) { if (t.b!=null) {
matWorld = Matrix.MakeTranslation(t.b.pos.x,t.b.pos.y,t.b.pos.z); matWorld = Matrix.MakeTranslation(t.b.pos.x+0.5f,t.b.pos.y,t.b.pos.z+0.5f);
} }
triRotation.A = Matrix.MultiplyVector(matWorld,triTransformed.A); triRotation.A = Matrix.MultiplyVector(matWorld,triTransformed.A);

@ -66,6 +66,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
public static float roll = 0; public static float roll = 0;
final static float MOVESPEED = FLYING_MODE?0.2f:0.075f; final static float MOVESPEED = FLYING_MODE?0.2f:0.075f;
private static final float JUMP_HEIGHT = 0.21f;
final static float TURNSPEED = 0.004f; final static float TURNSPEED = 0.004f;
public static float gravity = 0.01f; public static float gravity = 0.01f;
public static float fallSpd = 0; public static float fallSpd = 0;
@ -171,7 +172,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
public void runGameLoop() { public void runGameLoop() {
if (!FLYING_MODE) { if (!FLYING_MODE) {
move(); move();
if (checkCollisionSquare(0,-gravity,0)) { if (checkCollisionSquare(0,fallSpd-gravity,0)) {
fallSpd=Math.max(-maxCameraSpeed.y,fallSpd-gravity); fallSpd=Math.max(-maxCameraSpeed.y,fallSpd-gravity);
friction(vCameraSpeed,0.004f); //Air friction. friction(vCameraSpeed,0.004f); //Air friction.
} else { } else {
@ -179,7 +180,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
friction(vCameraSpeed,MOVESPEED/4); friction(vCameraSpeed,MOVESPEED/4);
} }
if (fallSpd<0) { if (fallSpd<0) {
vCamera.y=(float)Math.ceil(vCamera.y); vCamera.y=(float)Math.floor(vCamera.y);
fallSpd=0; fallSpd=0;
jumpsAvailable=1; jumpsAvailable=1;
} }
@ -199,7 +200,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
if (spaceHeld&&jumpsAvailable==1&&fallSpd==0&&!checkCollisionSquare(0,-gravity,0)) { if (spaceHeld&&jumpsAvailable==1&&fallSpd==0&&!checkCollisionSquare(0,-gravity,0)) {
jumpsAvailable=0; jumpsAvailable=0;
fallSpd=0.2f; fallSpd=JUMP_HEIGHT;
} }
} }

Loading…
Cancel
Save