v0.6.5: sped up loading transitions in many cases, reduced falling animation speed

This commit is contained in:
Evan Debenham 2018-05-01 19:38:36 -04:00 committed by Evan Debenham
parent cad4ffd62d
commit 9c43207e07

View File

@ -49,8 +49,15 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
public class InterlevelScene extends PixelScene { public class InterlevelScene extends PixelScene {
private static final float TIME_TO_FADE = 1f; //slow fade on entering a new region
private static final float SLOW_FADE = 1f; //.33 in, 1.33 steady, .33 out, 2 seconds total
//norm fade when loading, falling, returning, or descending to a new floor
private static final float NORM_FADE = 0.67f; //.33 in, .67 steady, .33 out, 1.33 seconds total
//fast fade when ascending, or descending to a floor you've been on
private static final float FAST_FADE = 0.50f; //.33 in, .33 steady, .33 out, 1 second total
private static float fadeTime;
public enum Mode { public enum Mode {
DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET, NONE DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET, NONE
@ -83,6 +90,7 @@ public class InterlevelScene extends PixelScene {
String loadingAsset; String loadingAsset;
int loadingDepth; int loadingDepth;
final float scrollSpeed; final float scrollSpeed;
fadeTime = NORM_FADE;
switch (mode){ switch (mode){
default: default:
loadingDepth = Dungeon.depth; loadingDepth = Dungeon.depth;
@ -93,15 +101,26 @@ public class InterlevelScene extends PixelScene {
scrollSpeed = 5; scrollSpeed = 5;
break; break;
case DESCEND: case DESCEND:
if (Dungeon.hero == null) loadingDepth = 1; if (Dungeon.hero == null){
else loadingDepth = Dungeon.depth+1; loadingDepth = 1;
fadeTime = SLOW_FADE;
} else {
loadingDepth = Dungeon.depth+1;
if (!(Statistics.deepestFloor < loadingDepth)) {
fadeTime = FAST_FADE;
} else if (loadingDepth == 6 || loadingDepth == 11
|| loadingDepth == 16 || loadingDepth == 22) {
fadeTime = SLOW_FADE;
}
}
scrollSpeed = 5; scrollSpeed = 5;
break; break;
case FALL: case FALL:
loadingDepth = Dungeon.depth+1; loadingDepth = Dungeon.depth+1;
scrollSpeed = 100; scrollSpeed = 50;
break; break;
case ASCEND: case ASCEND:
fadeTime = FAST_FADE;
loadingDepth = Dungeon.depth-1; loadingDepth = Dungeon.depth-1;
scrollSpeed = -5; scrollSpeed = -5;
break; break;
@ -114,7 +133,8 @@ public class InterlevelScene extends PixelScene {
else if (loadingDepth <= 10) loadingAsset = Assets.LOADING_PRISON; else if (loadingDepth <= 10) loadingAsset = Assets.LOADING_PRISON;
else if (loadingDepth <= 15) loadingAsset = Assets.LOADING_CAVES; else if (loadingDepth <= 15) loadingAsset = Assets.LOADING_CAVES;
else if (loadingDepth <= 21) loadingAsset = Assets.LOADING_CITY; else if (loadingDepth <= 21) loadingAsset = Assets.LOADING_CITY;
else loadingAsset = Assets.LOADING_HALLS; else if (loadingDepth <= 25) loadingAsset = Assets.LOADING_HALLS;
else loadingAsset = Assets.SHADOW;
SkinnedBlock bg = new SkinnedBlock(Camera.main.width, Camera.main.height, loadingAsset ){ SkinnedBlock bg = new SkinnedBlock(Camera.main.width, Camera.main.height, loadingAsset ){
@Override @Override
@ -142,8 +162,8 @@ public class InterlevelScene extends PixelScene {
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if (phase == Phase.FADE_IN) aa = Math.max( 0, timeLeft - 0.6f); if (phase == Phase.FADE_IN) aa = Math.max( 0, (timeLeft - (fadeTime - 0.333f)));
else if (phase == Phase.FADE_OUT) aa = Math.max( 0, 0.4f - (timeLeft)); else if (phase == Phase.FADE_OUT) aa = Math.max( 0, (0.333f - timeLeft));
else aa = 0; else aa = 0;
} }
}; };
@ -162,7 +182,7 @@ public class InterlevelScene extends PixelScene {
add( message ); add( message );
phase = Phase.FADE_IN; phase = Phase.FADE_IN;
timeLeft = TIME_TO_FADE; timeLeft = fadeTime;
if (thread == null) { if (thread == null) {
thread = new Thread() { thread = new Thread() {
@ -207,7 +227,7 @@ public class InterlevelScene extends PixelScene {
if (phase == Phase.STATIC && error == null) { if (phase == Phase.STATIC && error == null) {
phase = Phase.FADE_OUT; phase = Phase.FADE_OUT;
timeLeft = TIME_TO_FADE; timeLeft = fadeTime;
} }
} }
}; };
@ -222,7 +242,7 @@ public class InterlevelScene extends PixelScene {
waitingTime += Game.elapsed; waitingTime += Game.elapsed;
float p = timeLeft / TIME_TO_FADE; float p = timeLeft / fadeTime;
switch (phase) { switch (phase) {
@ -231,7 +251,7 @@ public class InterlevelScene extends PixelScene {
if ((timeLeft -= Game.elapsed) <= 0) { if ((timeLeft -= Game.elapsed) <= 0) {
if (!thread.isAlive() && error == null) { if (!thread.isAlive() && error == null) {
phase = Phase.FADE_OUT; phase = Phase.FADE_OUT;
timeLeft = TIME_TO_FADE; timeLeft = fadeTime;
} else { } else {
phase = Phase.STATIC; phase = Phase.STATIC;
} }