Skip to content

Commit da62870

Browse files
committed
FastJEngine refactor
1 parent 95313fd commit da62870

1 file changed

Lines changed: 21 additions & 27 deletions

File tree

src/main/java/tech/fastj/engine/FastJEngine.java

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,16 @@
3434
*/
3535
public class FastJEngine {
3636

37-
/**
38-
* Default engine value for "frames per second" of at least {@code 60}, depending on the monitor's refresh rate.
39-
*/
37+
/** Default engine value for "frames per second" of at least {@code 60}, depending on the monitor's refresh rate. */
4038
public static final int DefaultFPS = Math.max(DisplayUtil.getDefaultMonitorRefreshRate(), 60);
41-
/**
42-
* Default engine value for "updates per second" of {@code 60}.
43-
*/
39+
40+
/** Default engine value for "updates per second" of {@code 60}. */
4441
public static final int DefaultUPS = 60;
45-
/**
46-
* Default engine value for the window resolution of the {@link Display} of {@code 1280*720}.
47-
*/
42+
43+
/** Default engine value for the window resolution of the {@link Display} of {@code 1280*720}. */
4844
public static final Point DefaultWindowResolution = new Point(1280, 720);
49-
/**
50-
* Default engine value for the internal resolution of the {@link Display} of {@code 1280*720}.
51-
*/
45+
46+
/** Default engine value for the window resolution of the {@link Display} of {@code 1280*720}. */
5247
public static final Point DefaultInternalResolution = new Point(1280, 720);
5348

5449
// engine speed variables
@@ -207,9 +202,13 @@ public static void configureHardwareAcceleration(HWAccel hardwareAcceleration) {
207202
}
208203

209204
private static boolean isSystemSupportingHA(HWAccel hardwareAcceleration) {
210-
if (hardwareAcceleration.equals(HWAccel.Direct3D)) return System.getProperty("os.name").startsWith("Win");
211-
else if (hardwareAcceleration.equals(HWAccel.X11)) return System.getProperty("os.name").startsWith("Linux");
212-
else return true;
205+
if (hardwareAcceleration.equals(HWAccel.Direct3D)) {
206+
return System.getProperty("os.name").startsWith("Win");
207+
}
208+
else if (hardwareAcceleration.equals(HWAccel.X11)) {
209+
return System.getProperty("os.name").startsWith("Linux");
210+
}
211+
return true;
213212
}
214213

215214
/**
@@ -308,6 +307,7 @@ public static void setTargetUPS(int ups) {
308307
* In both situations, the game engine will be closed via {@link FastJEngine#forceCloseGame()} beforehand.
309308
*
310309
* @param shouldThrowExceptions The {@code boolean} to set whether exceptions should be thrown.
310+
*
311311
* @since 1.5.0
312312
*/
313313
public static void setShouldThrowExceptions(boolean shouldThrowExceptions) {
@@ -359,9 +359,7 @@ public static double getFPSData(FPSValue dataType) {
359359
}
360360
}
361361

362-
/**
363-
* Runs the game.
364-
*/
362+
/** Runs the game. */
365363
public static void run() {
366364
initEngine();
367365
try {
@@ -442,6 +440,7 @@ public static <T> void error(T errorMessage, Exception exception) {
442440
* otherwise, such as adding a game object to a scene while in an {@link LogicManager#update(Display)} call.
443441
*
444442
* @param action Disposable action to be run after the next {@link LogicManager#update(Display)} call.
443+
*
445444
* @since 1.4.0
446445
*/
447446
public static void runAfterUpdate(Runnable action) {
@@ -455,15 +454,14 @@ public static void runAfterUpdate(Runnable action) {
455454
* otherwise, such as adding a game object to a scene while in an {@link LogicManager#update(Display)} call.
456455
*
457456
* @param action Disposable action to be run after the next {@link LogicManager#render(Display)} call.
457+
*
458458
* @since 1.5.0
459459
*/
460460
public static void runAfterRender(Runnable action) {
461461
AfterRenderList.add(action);
462462
}
463463

464-
/**
465-
* Initializes the game engine's components.
466-
*/
464+
/** Initializes the game engine's components. */
467465
private static void initEngine() {
468466
runningCheck();
469467
isRunning = true;
@@ -482,9 +480,7 @@ private static void initEngine() {
482480
display.open();
483481
}
484482

485-
/**
486-
* Runs the game loop -- the heart of the engine.
487-
*/
483+
/** Runs the game loop -- the heart of the engine. */
488484
private static void gameLoop() {
489485
float elapsedTime;
490486
float accumulator = 0f;
@@ -545,9 +541,7 @@ private static void sync() {
545541
}
546542
}
547543

548-
/**
549-
* Removes all resources created by the game engine.
550-
*/
544+
/** Removes all resources created by the game engine. */
551545
private static void exit() {
552546
if (fpsLogger != null) {
553547
fpsLogger.shutdownNow();

0 commit comments

Comments
 (0)