Cleanup SplashScene class
This commit is contained in:
@@ -4,7 +4,7 @@ import java.util.EnumMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
final class SceneManager {
|
public final class SceneManager {
|
||||||
private static final SceneType DEFAULT_SCENE_TYPE = SceneType.SPLASH;
|
private static final SceneType DEFAULT_SCENE_TYPE = SceneType.SPLASH;
|
||||||
|
|
||||||
private static final EnumMap<SceneType, Scene> SCENES =
|
private static final EnumMap<SceneType, Scene> SCENES =
|
||||||
@@ -19,4 +19,8 @@ final class SceneManager {
|
|||||||
public static void setScene(SceneType sType) {
|
public static void setScene(SceneType sType) {
|
||||||
scene = SCENES.get(sType);
|
scene = SCENES.get(sType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void update() {
|
||||||
|
scene.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,26 @@ import java.util.Objects;
|
|||||||
import org.hirw.game.util.Time;
|
import org.hirw.game.util.Time;
|
||||||
|
|
||||||
public class SplashScene extends Scene {
|
public class SplashScene extends Scene {
|
||||||
private float ramp = 0.0f;
|
private final float INITIAL_BRIGHTNESS = 0.0f;
|
||||||
|
private final float FADE_RATE = 0.5f;
|
||||||
|
|
||||||
|
private float brightness;
|
||||||
|
|
||||||
|
public SplashScene() {
|
||||||
|
this.brightness = INITIAL_BRIGHTNESS;
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if (Objects.isNull(Window.get().getGlfwWindow())) {
|
if (Objects.isNull(Window.get().getGlfwWindow())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glClearColor(this.ramp, this.ramp, this.ramp, 0.0f);
|
fadeIn();
|
||||||
this.ramp += 0.5f * Time.deltaTime();
|
}
|
||||||
|
|
||||||
|
private void fadeIn() {
|
||||||
|
glClearColor(this.brightness, this.brightness, this.brightness, 0.0f);
|
||||||
|
final float fadeAmount = FADE_RATE * Time.deltaTime();
|
||||||
|
this.brightness += fadeAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class Window {
|
|||||||
private void loop() {
|
private void loop() {
|
||||||
while (!glfwWindowShouldClose(glfwWindow)) {
|
while (!glfwWindowShouldClose(glfwWindow)) {
|
||||||
Time.update();
|
Time.update();
|
||||||
SceneManager.getScene().update();
|
SceneManager.update();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
this.shader.update();
|
this.shader.update();
|
||||||
glfwSwapBuffers(glfwWindow);
|
glfwSwapBuffers(glfwWindow);
|
||||||
|
|||||||
Reference in New Issue
Block a user