Initialize Project Sacrifice backlog and source baseline

This commit is contained in:
2026-08-18 00:46:42 +03:00
parent d28ea8c3fd
commit 29d4a2d8d8
34 changed files with 4630 additions and 151 deletions
@@ -0,0 +1,29 @@
package com.projectsacrifice.game;
public final class GameMath {
private GameMath() {}
public static float clamp(float value, float min, float max) {
return Math.max(min, Math.min(max, value));
}
public static boolean intersects(
float ax, float ay, float aw, float ah,
float bx, float by, float bw, float bh
) {
return ax < bx + bw && ax + aw > bx && ay < by + bh && ay + ah > by;
}
public static float pingPong(float elapsedSeconds, float periodSeconds) {
if (periodSeconds <= 0f) return 0f;
double phase = (elapsedSeconds % periodSeconds) / periodSeconds;
return (float) ((1d - Math.cos(phase * Math.PI * 2d)) * 0.5d);
}
public static String formatTime(long elapsedMs) {
long totalSeconds = Math.max(0L, elapsedMs) / 1000L;
long minutes = totalSeconds / 60L;
long seconds = totalSeconds % 60L;
return String.format(java.util.Locale.US, "%02d:%02d", minutes, seconds);
}
}