Aufgabe 13

edited class BattleState in order to implement the 2D map feature
edited class GameSound to add the Missile launch sound
edited class MapViewSynchronizer in order to implement the 2D map feature
edited class ImpactEffectManager removed unused import
edited class SeaSynchronizer removed unused code
edited class Shell in order to implement the 2D map feature
edited class ShellControl in order to implement the 2D map feature
edited Sound added Missile launch enum
edited FloatMath to improve the animation for the 2D projectile
added missileLaunch.wav
This commit is contained in:
Lukas Bauer
2024-10-11 14:23:49 +02:00
parent 6100e95e76
commit bf16a18b71
11 changed files with 176 additions and 65 deletions

View File

@@ -96,6 +96,51 @@ public static float extrapolateLinear(float scale, float startValue, float endVa
return ((1f - scale) * startValue) + (scale * endValue);
}
/**
* Interpolates a value to range [0,1] after given easing function
* https://easings.net/#easeInOutElastic
* @param value the value to interpolate
* @return A new value in range [0,1]
*/
public static float easeInOutElastic(float value) {
var c5 = (2 * Math.PI) / 4.5;
return value == 0
? 0
: (float) (value == 1
? 1
: value < 0.5
? -(Math.pow(2, 20 * value - 10) * Math.sin((20 * value - 11.125) * c5)) / 2
: (Math.pow(2, -20 * value + 10) * Math.sin((20 * value - 11.125) * c5)) / 2 + 1);
}
/**
* Fancy effect for 2D Map animation
* @param x Progress state of animation
* @return new Value for animation
*/
public static float easeOutBounce(float x) {
float n1 = 7.5625f;
float d1 = 2.75f;
if (x < 1 / d1) {
return n1 * x * x;
} else if (x < 2 / d1) {
return (float) (n1 * (x -= 1.5 / d1) * x + 0.75);
} else if (x < 2.5 / d1) {
return (float) (n1 * (x -= 2.25 / d1) * x + 0.9375);
} else {
return (float) (n1 * (x -= 2.625 / d1) * x + 0.984375);
}
}
public static float easeInBounce(float x) {
return 1 - easeOutBounce(1 - x);
}
/**
* Returns the arc cosine of a value.<br>
* Special cases: