This commit is contained in:
@@ -54,7 +54,6 @@ public class LeaderboardRenderer {
|
||||
}
|
||||
|
||||
public void render() {
|
||||
ImGui.text("Placeholder for timer");
|
||||
var displaySize = ImGui.getIO().getDisplaySize();
|
||||
ImGui.setCursorPosX(displaySize.x / 2.0f - cellSize.x / 2.0f);
|
||||
ImGui.beginChild("Leaderboard", new ImVec2(cellSize.x + 15.0f, cellHeight * maxPlayersShowed));
|
||||
|
||||
27
app/src/main/java/gui/widget/TimerRenderer.java
Normal file
27
app/src/main/java/gui/widget/TimerRenderer.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package gui.widget;
|
||||
|
||||
import imgui.ImGui;
|
||||
|
||||
public class TimerRenderer {
|
||||
|
||||
private float time;
|
||||
private final float duration;
|
||||
|
||||
public TimerRenderer(float duration) {
|
||||
this.time = 0;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void render() {
|
||||
this.time += ImGui.getIO().getDeltaTime();
|
||||
float remainingTime = this.duration - this.time;
|
||||
int seconds = (int) remainingTime;
|
||||
int minutes = seconds / 60;
|
||||
seconds %= 60;
|
||||
String text = minutes + ":" + seconds;
|
||||
var textSize = ImGui.calcTextSize(text);
|
||||
ImGui.setCursorPosX(ImGui.getIO().getDisplaySizeX() / 2.0f - textSize.x / 2.0f);
|
||||
ImGui.text(text);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user