Fixed screen shake moving camera pan position
This commit is contained in:
@@ -7,6 +7,7 @@ import arc.graphics.Texture.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.gl.*;
|
import arc.graphics.gl.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -45,6 +46,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
private Color clearColor = new Color(0f, 0f, 0f, 1f);
|
private Color clearColor = new Color(0f, 0f, 0f, 1f);
|
||||||
private float targetscale = Scl.scl(4), camerascale = targetscale, landscale, landTime, weatherAlpha, minZoomScl = Scl.scl(0.01f);
|
private float targetscale = Scl.scl(4), camerascale = targetscale, landscale, landTime, weatherAlpha, minZoomScl = Scl.scl(0.01f);
|
||||||
private float shakeIntensity, shaketime;
|
private float shakeIntensity, shaketime;
|
||||||
|
private Vec2 camShakeOffset = new Vec2();
|
||||||
|
|
||||||
public Renderer(){
|
public Renderer(){
|
||||||
camera = new Camera();
|
camera = new Camera();
|
||||||
@@ -112,12 +114,25 @@ public class Renderer implements ApplicationListener{
|
|||||||
landTime = 0f;
|
landTime = 0f;
|
||||||
graphics.clear(Color.black);
|
graphics.clear(Color.black);
|
||||||
}else{
|
}else{
|
||||||
updateShake(0.75f);
|
if(shaketime > 0){
|
||||||
|
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * 0.75f;
|
||||||
|
camShakeOffset.setToRandomDirection().scl(Mathf.random(intensity));
|
||||||
|
camera.position.add(camShakeOffset);
|
||||||
|
shakeIntensity -= 0.25f * Time.delta;
|
||||||
|
shaketime -= Time.delta;
|
||||||
|
shakeIntensity = Mathf.clamp(shakeIntensity, 0f, 100f);
|
||||||
|
}else{
|
||||||
|
camShakeOffset.setZero();
|
||||||
|
shakeIntensity = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
if(pixelator.enabled()){
|
if(pixelator.enabled()){
|
||||||
pixelator.drawPixelate();
|
pixelator.drawPixelate();
|
||||||
}else{
|
}else{
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
camera.position.sub(camShakeOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,18 +187,6 @@ public class Renderer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateShake(float scale){
|
|
||||||
if(shaketime > 0){
|
|
||||||
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * scale;
|
|
||||||
camera.position.add(Mathf.range(intensity), Mathf.range(intensity));
|
|
||||||
shakeIntensity -= 0.25f * Time.delta;
|
|
||||||
shaketime -= Time.delta;
|
|
||||||
shakeIntensity = Mathf.clamp(shakeIntensity, 0f, 100f);
|
|
||||||
}else{
|
|
||||||
shakeIntensity = 0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Events.fire(Trigger.preDraw);
|
Events.fire(Trigger.preDraw);
|
||||||
|
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ kapt.include.compile.classpath=false
|
|||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
#needed for android compilation
|
#needed for android compilation
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
archash=626d16628b5c1f69a4a8cbd720eb99bb278e8a1f
|
archash=58cab1a87e1ed024a0044c4639594dc22088c87e
|
||||||
|
|||||||
Reference in New Issue
Block a user