feat: animated background
All checks were successful
Linux arm64 / Build (push) Successful in 10m56s
All checks were successful
Linux arm64 / Build (push) Successful in 10m56s
This commit is contained in:
28
app/src/main/java/gui/AnimatedBackground.java
Normal file
28
app/src/main/java/gui/AnimatedBackground.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
import imgui.ImGui;
|
||||||
|
import imgui.ImVec2;
|
||||||
|
import imgui.flag.ImGuiWindowFlags;
|
||||||
|
|
||||||
|
public class AnimatedBackground {
|
||||||
|
|
||||||
|
private float backgroundOffset = 0;
|
||||||
|
|
||||||
|
public AnimatedBackground() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render() {
|
||||||
|
backgroundOffset += ImGui.getIO().getDeltaTime() / 10.0f * Options.BackgroundSpeed;
|
||||||
|
var displaySize = ImGui.getIO().getDisplaySize();
|
||||||
|
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
||||||
|
ImGui.setNextWindowSize(displaySize);
|
||||||
|
ImGui.begin("Background", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
||||||
|
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground
|
||||||
|
| ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoInputs);
|
||||||
|
ImGui.image(Images.BACKGROUND, displaySize, new ImVec2(backgroundOffset, backgroundOffset),
|
||||||
|
new ImVec2(1.0f + backgroundOffset, 1.0f + backgroundOffset));
|
||||||
|
ImGui.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,5 +3,6 @@ package gui;
|
|||||||
public class Options {
|
public class Options {
|
||||||
|
|
||||||
public static Symbols Symboles = Symbols.Numbers;
|
public static Symbols Symboles = Symbols.Numbers;
|
||||||
|
public static float BackgroundSpeed = 1.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import imgui.type.ImInt;
|
|||||||
public class OptionsMenu extends BaseView {
|
public class OptionsMenu extends BaseView {
|
||||||
|
|
||||||
private ImInt currentValue = new ImInt();
|
private ImInt currentValue = new ImInt();
|
||||||
|
private float backgroundSpeed[] = new float[]{Options.BackgroundSpeed};
|
||||||
|
|
||||||
public OptionsMenu(StateMachine stateMachine) {
|
public OptionsMenu(StateMachine stateMachine) {
|
||||||
super(stateMachine);
|
super(stateMachine);
|
||||||
@@ -19,6 +20,9 @@ public class OptionsMenu extends BaseView {
|
|||||||
if(ImGui.combo("Jeu de symboles", currentValue, Symbols.getSymbolsNames())){
|
if(ImGui.combo("Jeu de symboles", currentValue, Symbols.getSymbolsNames())){
|
||||||
Options.Symboles = Symbols.values()[currentValue.get()];
|
Options.Symboles = Symbols.values()[currentValue.get()];
|
||||||
}
|
}
|
||||||
|
if(ImGui.sliderFloat("Vitesse d'animation de l'arrière plan", backgroundSpeed, 0.0f, 10.0f)){
|
||||||
|
Options.BackgroundSpeed = backgroundSpeed[0];
|
||||||
|
}
|
||||||
renderReturnButton();
|
renderReturnButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package gui.menu;
|
|||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import gui.Images;
|
import gui.AnimatedBackground;
|
||||||
import imgui.ImGui;
|
import imgui.ImGui;
|
||||||
import imgui.ImVec2;
|
import imgui.ImVec2;
|
||||||
import imgui.flag.ImGuiKey;
|
import imgui.flag.ImGuiKey;
|
||||||
@@ -11,9 +11,11 @@ import imgui.flag.ImGuiWindowFlags;
|
|||||||
public class StateMachine {
|
public class StateMachine {
|
||||||
|
|
||||||
private final Stack<BaseView> menus;
|
private final Stack<BaseView> menus;
|
||||||
|
private final AnimatedBackground background;
|
||||||
|
|
||||||
public StateMachine() {
|
public StateMachine() {
|
||||||
this.menus = new Stack<>();
|
this.menus = new Stack<>();
|
||||||
|
this.background = new AnimatedBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
@@ -40,12 +42,7 @@ public class StateMachine {
|
|||||||
|
|
||||||
public void render() {
|
public void render() {
|
||||||
var displaySize = ImGui.getIO().getDisplaySize();
|
var displaySize = ImGui.getIO().getDisplaySize();
|
||||||
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
this.background.render();
|
||||||
ImGui.setNextWindowSize(displaySize);
|
|
||||||
ImGui.begin("Background", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
|
||||||
| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoInputs);
|
|
||||||
ImGui.image(Images.BACKGROUND, displaySize, new ImVec2(0, 0));
|
|
||||||
ImGui.end();
|
|
||||||
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
|
||||||
ImGui.setNextWindowSize(displaySize);
|
ImGui.setNextWindowSize(displaySize);
|
||||||
ImGui.begin("##Main Window", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
ImGui.begin("##Main Window", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
|
||||||
|
|||||||
Reference in New Issue
Block a user