From 574a51154dce7abc98e31dcaba6fa0a70fd788f3 Mon Sep 17 00:00:00 2001 From: String Date: Thu, 22 Jan 2026 04:01:42 -0600 Subject: [PATCH] Moved everything into its own folder (especially FlixelGDX) --- .editorconfig | 2 +- .../funkin/android/AndroidLauncher.java | 11 +- assets/another_test.groovy | 24 +- assets/shared/images/characters/Nene.xml | 4 +- .../shared/images/characters/Pico_Death.xml | 4 +- assets/test.groovy | 25 +- .../Funkin.java => flixelgdx/Flixel.java} | 154 +++++----- .../stringfromjava/flixelgdx/FlixelGame.java | 271 ++++++++++++++++++ .../backend/FlixelPaths.java} | 6 +- .../graphics/screen/FlixelScreen.java} | 10 +- .../graphics/sprite/FlixelObject.java | 9 + .../graphics/sprite/FlixelSprite.java} | 18 +- .../graphics/text/FlixelText.java} | 6 +- .../signal/FlixelSignal.java} | 6 +- .../flixelgdx/signal/FlixelSignalData.java | 22 ++ .../tween/FlixelEase.java} | 12 +- .../tween/FlixelTween.java} | 68 ++--- .../tween/FlixelTweenManager.java} | 18 +- .../tween/settings/FlixelTweenSettings.java} | 57 ++-- .../tween/settings/FlixelTweenType.java} | 4 +- .../util/FlixelConstants.java} | 26 +- .../util/FlixelReflectUtil.java} | 10 +- .../util/FlixelRuntimeUtil.java} | 9 +- .../me/stringfromjava/funkin/FunkinGame.java | 227 ++------------- .../funkin/game/InitScreen.java | 14 - .../funkin/game/menus/TitleScreen.java | 90 ------ .../funkin/graphics/sprite/FunkinObject.java | 7 - .../funkin/init/InitScreen.java | 14 + .../funkin/menus/TitleScreen.java | 90 ++++++ .../funkin/util/FunkinConstants.java | 26 ++ .../funkin/util/signal/FunkinSignalData.java | 32 --- .../{funkin => }/polyverse/Polyverse.java | 16 +- .../polyverse/script/type/Script.java | 2 +- .../polyverse/script/type/SystemScript.java | 2 +- .../funkin/lwjgl3/Lwjgl3Launcher.java | 30 +- 35 files changed, 710 insertions(+), 616 deletions(-) rename core/src/main/java/me/stringfromjava/{funkin/Funkin.java => flixelgdx/Flixel.java} (75%) create mode 100644 core/src/main/java/me/stringfromjava/flixelgdx/FlixelGame.java rename core/src/main/java/me/stringfromjava/{funkin/backend/Paths.java => flixelgdx/backend/FlixelPaths.java} (86%) rename core/src/main/java/me/stringfromjava/{funkin/graphics/screen/FunkinScreen.java => flixelgdx/graphics/screen/FlixelScreen.java} (77%) create mode 100644 core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelObject.java rename core/src/main/java/me/stringfromjava/{funkin/graphics/sprite/FunkinSprite.java => flixelgdx/graphics/sprite/FlixelSprite.java} (95%) rename core/src/main/java/me/stringfromjava/{funkin/graphics/text/FunkinText.java => flixelgdx/graphics/text/FlixelText.java} (78%) rename core/src/main/java/me/stringfromjava/{funkin/util/signal/FunkinSignal.java => flixelgdx/signal/FlixelSignal.java} (95%) create mode 100644 core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignalData.java rename core/src/main/java/me/stringfromjava/{funkin/tween/FunkinEase.java => flixelgdx/tween/FlixelEase.java} (96%) rename core/src/main/java/me/stringfromjava/{funkin/tween/FunkinTween.java => flixelgdx/tween/FlixelTween.java} (84%) rename core/src/main/java/me/stringfromjava/{funkin/tween/FunkinTweenManager.java => flixelgdx/tween/FlixelTweenManager.java} (70%) rename core/src/main/java/me/stringfromjava/{funkin/tween/settings/FunkinTweenSettings.java => flixelgdx/tween/settings/FlixelTweenSettings.java} (66%) rename core/src/main/java/me/stringfromjava/{funkin/tween/settings/FunkinTweenType.java => flixelgdx/tween/settings/FlixelTweenType.java} (84%) rename core/src/main/java/me/stringfromjava/{funkin/util/Constants.java => flixelgdx/util/FlixelConstants.java} (61%) rename core/src/main/java/me/stringfromjava/{funkin/util/FunkinReflectUtil.java => flixelgdx/util/FlixelReflectUtil.java} (90%) rename core/src/main/java/me/stringfromjava/{funkin/util/FunkinRuntimeUtil.java => flixelgdx/util/FlixelRuntimeUtil.java} (92%) delete mode 100644 core/src/main/java/me/stringfromjava/funkin/game/InitScreen.java delete mode 100644 core/src/main/java/me/stringfromjava/funkin/game/menus/TitleScreen.java delete mode 100644 core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinObject.java create mode 100644 core/src/main/java/me/stringfromjava/funkin/init/InitScreen.java create mode 100644 core/src/main/java/me/stringfromjava/funkin/menus/TitleScreen.java create mode 100644 core/src/main/java/me/stringfromjava/funkin/util/FunkinConstants.java delete mode 100644 core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignalData.java rename core/src/main/java/me/stringfromjava/{funkin => }/polyverse/Polyverse.java (91%) rename core/src/main/java/me/stringfromjava/{funkin => }/polyverse/script/type/Script.java (91%) rename core/src/main/java/me/stringfromjava/{funkin => }/polyverse/script/type/SystemScript.java (66%) diff --git a/.editorconfig b/.editorconfig index def4063..179b03d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -24,7 +24,7 @@ ij_java_names_count_to_use_import_on_demand = 999 ij_java_packages_to_use_import_on_demand = unset ij_java_blank_lines_before_class_end = 0 ij_java_blank_lines_after_class_header = 1 -ij_java_doc_align_param_comments = true +ij_java_doc_align_param_comments = false ij_java_doc_do_not_wrap_if_one_line = true ij_any_keep_simple_blocks_in_one_line = true diff --git a/android/src/main/java/me/stringfromjava/funkin/android/AndroidLauncher.java b/android/src/main/java/me/stringfromjava/funkin/android/AndroidLauncher.java index 0898de2..2b41d46 100644 --- a/android/src/main/java/me/stringfromjava/funkin/android/AndroidLauncher.java +++ b/android/src/main/java/me/stringfromjava/funkin/android/AndroidLauncher.java @@ -3,7 +3,10 @@ import android.os.Bundle; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; +import me.stringfromjava.flixelgdx.FlixelGame; import me.stringfromjava.funkin.FunkinGame; +import me.stringfromjava.funkin.init.InitScreen; +import me.stringfromjava.funkin.util.FunkinConstants; /** Launches the Android application. */ public class AndroidLauncher extends AndroidApplication { @@ -11,8 +14,14 @@ public class AndroidLauncher extends AndroidApplication { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + FunkinGame game = new FunkinGame( + FunkinConstants.WINDOW_TITLE, + FunkinConstants.WINDOW_WIDTH, + FunkinConstants.WINDOW_HEIGHT, + new InitScreen() + ); AndroidApplicationConfiguration configuration = new AndroidApplicationConfiguration(); configuration.useImmersiveMode = true; // Recommended, but not required. - initialize(new FunkinGame(), configuration); + initialize(game, configuration); } } diff --git a/assets/another_test.groovy b/assets/another_test.groovy index b162bc9..a7a42b6 100644 --- a/assets/another_test.groovy +++ b/assets/another_test.groovy @@ -1,10 +1,10 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.Input -import me.stringfromjava.funkin.Funkin -import me.stringfromjava.funkin.backend.Paths -import me.stringfromjava.funkin.graphics.sprite.FunkinSprite -import me.stringfromjava.funkin.polyverse.script.type.Script -import me.stringfromjava.funkin.util.Constants +import me.stringfromjava.flixelgdx.Flixel +import me.stringfromjava.flixelgdx.backend.FlixelPaths +import me.stringfromjava.flixelgdx.graphics.sprite.FlixelSprite +import me.stringfromjava.funkin.util.FunkinConstants +import me.stringfromjava.polyverse.script.type.Script class AnotherTestClass extends Script { @@ -16,9 +16,9 @@ class AnotherTestClass extends Script { void onCreate() { super.onCreate() - Funkin.info("AnotherTestClass", "Script has been created!") + Flixel.info("AnotherTestClass", "Script has been created!") - Funkin.playMusic("songs/bopeebo/Inst.ogg") + Flixel.playMusic("songs/bopeebo/Inst.ogg") } @Override @@ -26,13 +26,13 @@ class AnotherTestClass extends Script { super.onRender(delta) if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) { - var sprite = new FunkinSprite().loadGraphic(Paths.sharedImageAsset("pauseAlt/bfLol")) - var randomPosX = new Random().nextInt(Constants.Display.WINDOW_WIDTH) - var randomPosY = new Random().nextInt(Constants.Display.WINDOW_HEIGHT) + var sprite = new FlixelSprite().loadGraphic(FlixelPaths.sharedImageAsset("pauseAlt/bfLol")) + var randomPosX = new Random().nextInt(FunkinConstants.WINDOW_WIDTH) + var randomPosY = new Random().nextInt(FunkinConstants.WINDOW_HEIGHT) sprite.setPosition(randomPosX, randomPosY) - Funkin.screen.add(sprite) + Flixel.screen.add(sprite) } } @@ -40,6 +40,6 @@ class AnotherTestClass extends Script { void onDispose() { super.onDispose() - Funkin.info("AnotherTestClass", "Script has been disposed!") + Flixel.info("AnotherTestClass", "Script has been disposed!") } } diff --git a/assets/shared/images/characters/Nene.xml b/assets/shared/images/characters/Nene.xml index 3b2d96c..0dd32df 100644 --- a/assets/shared/images/characters/Nene.xml +++ b/assets/shared/images/characters/Nene.xml @@ -1,6 +1,6 @@ @@ -119,4 +119,4 @@ Created with Funkin Packer v0.1.3 https://neeeoo.github.io/funkin-packer/ - \ No newline at end of file + diff --git a/assets/shared/images/characters/Pico_Death.xml b/assets/shared/images/characters/Pico_Death.xml index 152c157..6a980c0 100644 --- a/assets/shared/images/characters/Pico_Death.xml +++ b/assets/shared/images/characters/Pico_Death.xml @@ -1,6 +1,6 @@ @@ -67,4 +67,4 @@ Created with Funkin Packer v0.1.3 https://neeeoo.github.io/funkin-packer/ - \ No newline at end of file + diff --git a/assets/test.groovy b/assets/test.groovy index 452a41d..c16d287 100644 --- a/assets/test.groovy +++ b/assets/test.groovy @@ -1,12 +1,11 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Color -import com.badlogic.gdx.graphics.Texture -import me.stringfromjava.funkin.Funkin -import me.stringfromjava.funkin.graphics.screen.FunkinScreen -import me.stringfromjava.funkin.backend.Paths -import me.stringfromjava.funkin.graphics.sprite.FunkinSprite -import me.stringfromjava.funkin.polyverse.script.type.SystemScript +import me.stringfromjava.flixelgdx.Flixel +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen +import me.stringfromjava.flixelgdx.backend.FlixelPaths +import me.stringfromjava.flixelgdx.graphics.sprite.FlixelSprite +import me.stringfromjava.polyverse.script.type.SystemScript class TestScript extends SystemScript { @@ -17,7 +16,7 @@ class TestScript extends SystemScript { @Override void onCreate() { super.onCreate() - Funkin.info("TestScript", "Script has been created!") + Flixel.info("TestScript", "Script has been created!") } @Override @@ -25,31 +24,31 @@ class TestScript extends SystemScript { super.onRender(delta) if (Gdx.input.isKeyJustPressed(Input.Keys.Q)) { - Funkin.setScreen(new TestScreen()) + Flixel.setScreen(new TestScreen()) } } @Override void onDispose() { super.onDispose() - Funkin.info("TestClass", "Script has been disposed!") + Flixel.info("TestClass", "Script has been disposed!") } } -class TestScreen extends FunkinScreen { +class TestScreen extends FlixelScreen { - private FunkinSprite test + private FlixelSprite test @Override void show() { super.show() - test = new FunkinSprite().loadGraphic(Paths.sharedImageAsset('NOTE_hold_assets')) + test = new FlixelSprite().loadGraphic(FlixelPaths.sharedImageAsset('NOTE_hold_assets')) add(test) bgColor = new Color(0, 1, 0, 1) - Funkin.playMusic('songs/darnell/Inst.ogg') + Flixel.playMusic('songs/darnell/Inst.ogg') } @Override diff --git a/core/src/main/java/me/stringfromjava/funkin/Funkin.java b/core/src/main/java/me/stringfromjava/flixelgdx/Flixel.java similarity index 75% rename from core/src/main/java/me/stringfromjava/funkin/Funkin.java rename to core/src/main/java/me/stringfromjava/flixelgdx/Flixel.java index f722901..8188577 100644 --- a/core/src/main/java/me/stringfromjava/funkin/Funkin.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/Flixel.java @@ -1,4 +1,4 @@ -package me.stringfromjava.funkin; +package me.stringfromjava.flixelgdx; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.AssetManager; @@ -8,28 +8,27 @@ import games.rednblack.miniaudio.MASound; import games.rednblack.miniaudio.MiniAudio; import games.rednblack.miniaudio.loader.MASoundLoader; -import me.stringfromjava.funkin.graphics.screen.FunkinScreen; -import me.stringfromjava.funkin.util.Constants; -import me.stringfromjava.funkin.util.signal.FunkinSignal; -import me.stringfromjava.funkin.util.signal.FunkinSignalData.MusicPlayedSignalData; -import me.stringfromjava.funkin.util.signal.FunkinSignalData.RenderSignalData; -import me.stringfromjava.funkin.util.signal.FunkinSignalData.ScreenSwitchSignalData; -import me.stringfromjava.funkin.util.signal.FunkinSignalData.SoundPlayedSignalData; +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; +import me.stringfromjava.flixelgdx.util.FlixelConstants; +import me.stringfromjava.flixelgdx.signal.FlixelSignal; +import me.stringfromjava.flixelgdx.signal.FlixelSignalData.MusicPlayedSignalData; +import me.stringfromjava.flixelgdx.signal.FlixelSignalData.RenderSignalData; +import me.stringfromjava.flixelgdx.signal.FlixelSignalData.ScreenSwitchSignalData; +import me.stringfromjava.flixelgdx.signal.FlixelSignalData.SoundPlayedSignalData; import org.jetbrains.annotations.NotNull; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; /** - * Global manager and utility class for the game. + * Global manager and utility class for Flixel. * - *

This is where you want to do the main things, like switching screens, playing sounds/music, - * etc. + *

This is where you want to do the main things, like switching screens, playing sounds/music, etc. */ -public final class Funkin { +public final class Flixel { - /** The current {@code FunkinScreen} being displayed. */ - private static FunkinScreen screen; + /** The current {@code FlixelScreen} being displayed. */ + private static FlixelScreen screen; /** The main audio object used to create, */ private static MiniAudio engine; @@ -50,7 +49,7 @@ public final class Funkin { * The static instance used to access the core elements of the game. This includes the main loop, * setting the current screen, and more. */ - private static FunkinGame game; + private static FlixelGame game; /** Has the global manager been initialized yet? */ private static boolean initialized = false; @@ -63,7 +62,7 @@ public final class Funkin { * * @param gameInstance The instance of the game to use. */ - public static void initialize(FunkinGame gameInstance) { + public static void initialize(FlixelGame gameInstance) { if (initialized) { throw new IllegalStateException("FNF:JE has already been initialized!"); } @@ -80,12 +79,11 @@ public static void initialize(FunkinGame gameInstance) { } /** - * Sets the current screen to the provided screen. This is just a more direct version of {@code - * Funkin.game.setScreen(screen)} with some extra functionality put into it. + * Sets the current screen to the provided screen. * - * @param newScreen The new {@code FunkinScreen} to set as the current screen. + * @param newScreen The new {@code FlixelScreen} to set as the current screen. */ - public static void setScreen(FunkinScreen newScreen) { + public static void setScreen(FlixelScreen newScreen) { Signals.preScreenSwitch.dispatch(new ScreenSwitchSignalData(newScreen)); if (!initialized) { throw new IllegalStateException("FNF:JE has not been initialized yet!"); @@ -93,12 +91,12 @@ public static void setScreen(FunkinScreen newScreen) { if (newScreen == null) { throw new IllegalArgumentException("Screen cannot be null!"); } - if (Funkin.screen != null) { - Funkin.screen.hide(); - Funkin.screen.dispose(); + if (Flixel.screen != null) { + Flixel.screen.hide(); + Flixel.screen.dispose(); } - Funkin.screen = newScreen; - Funkin.screen.show(); + Flixel.screen = newScreen; + Flixel.screen.show(); Signals.postScreenSwitch.dispatch(new ScreenSwitchSignalData(newScreen)); } @@ -109,8 +107,8 @@ public static void setScreen(FunkinScreen newScreen) { * FileHandle} like so: * *

{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
-   * Funkin.playSound(Paths.external("your/path/here").path());
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
+   * Flixel.playSound(FlixelPaths.external("your/path/here").path());
    * }
* * @param path The path to load the sound from. Note that if you're loading an external sound @@ -129,8 +127,8 @@ public static MASound playSound(String path) { * FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
-   * Funkin.playSound(Paths.external("your/path/here").path(), 1);
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
+   * Flixel.playSound(FlixelPaths.external("your/path/here").path(), 1);
    * }
* * @param path The path to load the sound from. Note that if you're loading an external sound @@ -150,8 +148,8 @@ public static MASound playSound(String path, float volume) { * FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
-   * Funkin.playSound(Paths.external("your/path/here").path(), 1, false);
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
+   * Flixel.playSound(FlixelPaths.external("your/path/here").path(), 1, false);
    * }
* * @param path The path to load the sound from. Note that if you're loading an external sound @@ -172,9 +170,9 @@ public static MASound playSound(String path, float volume, boolean looping) { * FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
    * // If null is passed down for the group, then the default sound group will be used.
-   * Funkin.playSound(Paths.external("your/path/here").path(), 1, false, null);
+   * Flixel.playSound(FlixelPaths.external("your/path/here").path(), 1, false, null);
    * }
* * @param path The path to load the sound from. Note that if you're loading an external sound @@ -197,11 +195,11 @@ public static MASound playSound(String path, float volume, boolean looping, MAGr * FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
    * // If null is passed down for the group, then the default sound group will be used.
    * // For the boolean attribuite "external", you only should make it true for mobile builds,
    * // otherwise just simply leave it be or make it "false" for other platforms like desktop.
-   * Funkin.playSound(Paths.external("your/path/here").path(), 1, false, null, true);
+   * Flixel.playSound(FlixelPaths.external("your/path/here").path(), 1, false, null, true);
    * }
* * @param path The path to load the sound from. Note that if you're loading an external sound @@ -231,8 +229,8 @@ public static MASound playSound(@NotNull String path, float volume, boolean loop * {@link FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
-   * Funkin.playMusic(Paths.external("your/path/here").path());
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
+   * Flixel.playMusic(FlixelPaths.external("your/path/here").path());
    * }
* * @param path The path to load the music from. Note that if you're loading an external sound file @@ -250,8 +248,8 @@ public static void playMusic(String path) { * {@link FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
-   * Funkin.playMusic(Paths.external("your/path/here").path(), 1);
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
+   * Flixel.playMusic(FlixelPaths.external("your/path/here").path(), 1);
    * }
* * @param path The path to load the music from. Note that if you're loading an external sound file @@ -270,8 +268,8 @@ public static void playMusic(String path, float volume) { * {@link FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
-   * Funkin.playMusic(Paths.external("your/path/here").path(), 1, false);
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
+   * Flixel.playMusic(FlixelPaths.external("your/path/here").path(), 1, false);
    * }
* * @param path The path to load the music from. Note that if you're loading an external sound file @@ -291,10 +289,10 @@ public static void playMusic(String path, float volume, boolean looping) { * {@link FileHandle} like so: * *
{@code
-   * // Notice how it uses the Paths class provided by Funkin'.
+   * // Notice how it uses the FlixelPaths class provided by Flixel'.
    * // For the boolean attribuite "external", you only should make it true for mobile builds,
    * // otherwise just simply leave it be or make it "false" for other platforms like desktop.
-   * Funkin.playMusic(Paths.external("your/path/here").path(), 1, false, true);
+   * Flixel.playMusic(FlixelPaths.external("your/path/here").path(), 1, false, true);
    * }
* * @param path The path to load the music from. Note that if you're loading an external sound file @@ -320,7 +318,7 @@ public static void playMusic(String path, float volume, boolean looping, boolean * Sets the game master/global volume, which is automatically applied to all current sounds. * *

(This is just a helper method for creating a faster version of {@code - * Funkin.getAudioEngine().setMasterVolume(float)}). + * Flixel.getAudioEngine().setMasterVolume(float)}). * * @param volume The new master volume to set. */ @@ -338,23 +336,23 @@ public static boolean keyJustPressed(int key) { } public static void info(Object message) { - info(Constants.System.LOG_TAG, message); + info(FlixelConstants.System.LOG_TAG, message); } public static void info(String tag, Object message) { - outputLog(tag, message, FunkinLogLevel.INFO); + outputLog(tag, message, FlixelLogLevel.INFO); } public static void warn(Object message) { - warn(Constants.System.LOG_TAG, message); + warn(FlixelConstants.System.LOG_TAG, message); } public static void warn(String tag, Object message) { - outputLog(tag, message, FunkinLogLevel.WARN); + outputLog(tag, message, FlixelLogLevel.WARN); } public static void error(String message) { - error(Constants.System.LOG_TAG, message, null); + error(FlixelConstants.System.LOG_TAG, message, null); } public static void error(String tag, Object message) { @@ -363,10 +361,10 @@ public static void error(String tag, Object message) { public static void error(String tag, Object message, Throwable throwable) { String msg = (throwable != null) ? (message + " | Exception: " + throwable) : message.toString(); - outputLog(tag, msg, FunkinLogLevel.ERROR); + outputLog(tag, msg, FlixelLogLevel.ERROR); } - public static FunkinGame getGame() { + public static FlixelGame getGame() { return game; } @@ -374,7 +372,7 @@ public static Stage getStage() { return game.stage; } - public static FunkinScreen getScreen() { + public static FlixelScreen getScreen() { return screen; } @@ -398,6 +396,10 @@ public static MAGroup getSoundsGroup() { return soundsGroup; } + public static float getDelta() { + return Gdx.graphics.getDeltaTime(); + } + /** * Contains all the global events that get dispatched when something happens in the game. * @@ -410,19 +412,19 @@ public static MAGroup getSoundsGroup() { */ public static final class Signals { - public static final FunkinSignal preRender = new FunkinSignal<>(); - public static final FunkinSignal postRender = new FunkinSignal<>(); - public static final FunkinSignal preScreenSwitch = new FunkinSignal<>(); - public static final FunkinSignal postScreenSwitch = new FunkinSignal<>(); - public static final FunkinSignal preGameClose = new FunkinSignal<>(); - public static final FunkinSignal postGameClose = new FunkinSignal<>(); - public static final FunkinSignal windowFocused = new FunkinSignal<>(); - public static final FunkinSignal windowUnfocused = new FunkinSignal<>(); - public static final FunkinSignal windowMinimized = new FunkinSignal<>(); - public static final FunkinSignal preSoundPlayed = new FunkinSignal<>(); - public static final FunkinSignal postSoundPlayed = new FunkinSignal<>(); - public static final FunkinSignal preMusicPlayed = new FunkinSignal<>(); - public static final FunkinSignal postMusicPlayed = new FunkinSignal<>(); + public static final FlixelSignal preRender = new FlixelSignal<>(); + public static final FlixelSignal postRender = new FlixelSignal<>(); + public static final FlixelSignal preScreenSwitch = new FlixelSignal<>(); + public static final FlixelSignal postScreenSwitch = new FlixelSignal<>(); + public static final FlixelSignal preGameClose = new FlixelSignal<>(); + public static final FlixelSignal postGameClose = new FlixelSignal<>(); + public static final FlixelSignal windowFocused = new FlixelSignal<>(); + public static final FlixelSignal windowUnfocused = new FlixelSignal<>(); + public static final FlixelSignal windowMinimized = new FlixelSignal<>(); + public static final FlixelSignal preSoundPlayed = new FlixelSignal<>(); + public static final FlixelSignal postSoundPlayed = new FlixelSignal<>(); + public static final FlixelSignal preMusicPlayed = new FlixelSignal<>(); + public static final FlixelSignal postMusicPlayed = new FlixelSignal<>(); private Signals() {} } @@ -431,7 +433,7 @@ private Signals() {} // UTILITY FUNCTIONS, IGNORE BELOW // ====================================== - private static void outputLog(String tag, Object message, FunkinLogLevel level) { + private static void outputLog(String tag, Object message, FlixelLogLevel level) { StackWalker.StackFrame caller = StackWalker.getInstance() .walk(s -> s.skip(3).findFirst()) .orElse(null); @@ -444,12 +446,12 @@ private static void outputLog(String tag, Object message, FunkinLogLevel level) } String color = switch (level) { - case INFO -> Constants.AsciiCodes.WHITE; - case WARN -> Constants.AsciiCodes.YELLOW; - case ERROR -> Constants.AsciiCodes.RED; + case INFO -> FlixelConstants.AsciiCodes.WHITE; + case WARN -> FlixelConstants.AsciiCodes.YELLOW; + case ERROR -> FlixelConstants.AsciiCodes.RED; }; - boolean underline = (level == FunkinLogLevel.ERROR); + boolean underline = (level == FlixelLogLevel.ERROR); String timeAndDate = colorText(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + " ", color, true, @@ -464,24 +466,24 @@ private static void outputLog(String tag, Object message, FunkinLogLevel level) private static String colorText(String text, String color, boolean bold, boolean italic, boolean underline) { StringBuilder sb = new StringBuilder(); if (bold) { - sb.append(Constants.AsciiCodes.BOLD); + sb.append(FlixelConstants.AsciiCodes.BOLD); } if (italic) { - sb.append(Constants.AsciiCodes.ITALIC); + sb.append(FlixelConstants.AsciiCodes.ITALIC); } if (underline) { - sb.append(Constants.AsciiCodes.UNDERLINE); + sb.append(FlixelConstants.AsciiCodes.UNDERLINE); } sb.append(color); sb.append(text); - sb.append(Constants.AsciiCodes.RESET); + sb.append(FlixelConstants.AsciiCodes.RESET); return sb.toString(); } - private Funkin() {} + private Flixel() {} } -enum FunkinLogLevel { +enum FlixelLogLevel { INFO, WARN, ERROR diff --git a/core/src/main/java/me/stringfromjava/flixelgdx/FlixelGame.java b/core/src/main/java/me/stringfromjava/flixelgdx/FlixelGame.java new file mode 100644 index 0000000..654f80d --- /dev/null +++ b/core/src/main/java/me/stringfromjava/flixelgdx/FlixelGame.java @@ -0,0 +1,271 @@ +package me.stringfromjava.flixelgdx; + +import com.badlogic.gdx.Application; +import com.badlogic.gdx.ApplicationListener; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.utils.viewport.FitViewport; +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; +import me.stringfromjava.flixelgdx.graphics.sprite.FlixelObject; +import me.stringfromjava.flixelgdx.graphics.sprite.FlixelSprite; +import me.stringfromjava.flixelgdx.tween.FlixelTween; +import me.stringfromjava.flixelgdx.util.FlixelConstants; +import me.stringfromjava.flixelgdx.util.FlixelRuntimeUtil; +import me.stringfromjava.funkin.util.FunkinConstants; +import me.stringfromjava.polyverse.Polyverse; +import me.stringfromjava.polyverse.script.type.Script; + +import static me.stringfromjava.flixelgdx.signal.FlixelSignalData.RenderSignalData; + +/** + * Flixel's enhanced game object used for containing the main loop and core elements of Flixel. + * + *

If you want to change what happens to the pre and window configurations, you might want to see + * {@code Lwjgl3Launcher} in the {@code lwjgl3} folder. + */ +public abstract class FlixelGame implements ApplicationListener { + + /** The title displayed on the game's window. */ + protected String title; + + /** The size of the game's starting window position and its viewport. */ + protected Vector2 size; + + /** The entry point screen the game starts in (which becomes null after the game is done setting up!). */ + protected FlixelScreen initialScreen; + + /** Is the game's window currently minimized? */ + protected boolean isMinimized = false; + + /** The main stage used for rendering all screens and sprites on screen. */ + protected Stage stage; + + /** The main viewport used to fit the world no matter the screen size. */ + protected FitViewport viewport; + + /** The main camera used to see the world. */ + protected OrthographicCamera camera; + + /** The main sprite batch used for rendering all sprites on screen. */ + protected SpriteBatch batch; + + /** The 1x1 texture used to draw the background color of the current screen. */ + protected Texture bgTexture; + + /** + * Creates a new game instance with the specified title, window width/height, and initial screen. This configures + * the game's core parts, such as the viewport, stage, etc. + * + * @param title The title of the game's window. + * @param width The starting width of the game's window and how wide the viewport should be. + * @param height The starting height of the game's window and how tall the viewport should be. + * @param initialScreen The initial screen to load when the game starts. + */ + public FlixelGame(String title, int width, int height, FlixelScreen initialScreen) { + this.title = title; + this.size = new Vector2(width, height); + this.initialScreen = initialScreen; + } + + @Override + public void create() { + configureCrashHandler(); // This should ALWAYS be called first no matter what! + + batch = new SpriteBatch(); + viewport = new FitViewport(size.x, size.y); + viewport.apply(); + + camera = new OrthographicCamera(); + camera.setToOrtho(false, size.x, size.y); + + stage = new Stage(viewport, batch); + + Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); + pixmap.setColor(Color.WHITE); + pixmap.fill(); + bgTexture = new Texture(pixmap); + pixmap.dispose(); + + Flixel.setScreen(initialScreen); + initialScreen = null; + } + + @Override + public void resize(int width, int height) { + viewport.update(width, height, true); + } + + @Override + public void render() { + float delta = Gdx.graphics.getDeltaTime(); + FlixelScreen screen = Flixel.getScreen(); + + Flixel.Signals.preRender.dispatch(new RenderSignalData(delta)); + + if (Flixel.keyJustPressed(Input.Keys.F11)) { + toggleFullscreen(); + } + + // Update and render the current screen that's active. + ScreenUtils.clear(Color.BLACK); + viewport.apply(); + batch.setProjectionMatrix(camera.combined); + batch.begin(); + + if (screen != null) { + batch.setColor(screen.getBgColor()); + batch.draw(bgTexture, 0, 0, viewport.getWorldWidth(), viewport.getWorldHeight()); + batch.setColor(Color.WHITE); // Set color back to white so display objects aren't affected. + screen.render(delta); + var members = screen.members.begin(); + for (FlixelObject object : members) { + if (object instanceof FlixelSprite sprite) { + sprite.update(delta); + sprite.draw(batch); + } + } + screen.members.end(); + } + + batch.end(); + stage.act(delta); + stage.draw(); + + FlixelTween.getGlobalManager().update(delta); + + Flixel.Signals.postRender.dispatch(new RenderSignalData(delta)); + } + + @Override + public void pause() {} + + @Override + public void resume() {} + + /** Called when the user regains focus on the game's window. */ + public void onWindowFocused() { + Flixel.setMasterVolume(1); + Flixel.Signals.windowFocused.dispatch(); + Flixel.info("Game window has regained focus."); + } + + /** Called when the user loses focus on the game's window, while also not being minimized. */ + public void onWindowUnfocused() { + if (isMinimized) { + return; + } + Flixel.setMasterVolume(0.008f); + Flixel.Signals.windowUnfocused.dispatch(); + Flixel.info("Game window has lost focus."); + } + + /** + * Called when the user minimizes the game's window. + * + * @param iconified Whether the window is iconified (minimized) or not. This parameter is provided + * for compatibility with the window listener in the LWJGL3 (desktop) launcher. + */ + public void onWindowMinimized(boolean iconified) { + isMinimized = iconified; + if (!isMinimized) { + return; + } + Flixel.setMasterVolume(0); + Flixel.Signals.windowMinimized.dispatch(); + Flixel.info("Game window has been minimized."); + } + + /** Toggles fullscreen mode on or off, depending on the current state. */ + public void toggleFullscreen() { + boolean isFullscreen = Gdx.graphics.isFullscreen(); + if (isFullscreen) { + Gdx.graphics.setWindowedMode(FunkinConstants.WINDOW_WIDTH, FunkinConstants.WINDOW_HEIGHT); + Flixel.info("Exiting fullscreen mode."); + } else { + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + Flixel.info("Entering fullscreen mode."); + } + } + + @Override + public void dispose() { + Flixel.warn("SHUTTING DOWN GAME AND DISPOSING ALL RESOURCES."); + + Flixel.Signals.preGameClose.dispatch(); + + Flixel.info("Disposing the screen display..."); + Flixel.getScreen().hide(); + Flixel.getScreen().dispose(); + stage.dispose(); + batch.dispose(); + bgTexture.dispose(); + + Flixel.info("Disposing all sounds from sound group and music..."); + if (Flixel.getMusic() != null) { + Flixel.getMusic().dispose(); + } + Flixel.getSoundsGroup().dispose(); + Flixel.getAudioEngine().dispose(); + + Flixel.info("Disposing and shutting down scripts..."); + Polyverse.forAllScripts(Script::onDispose); + + Flixel.Signals.postGameClose.dispatch(); + } + + public String getTitle() { + return title; + } + + public int[] getWindowSize() { + return new int[]{(int) size.x, (int) size.y}; + } + + public Stage getStage() { + return stage; + } + + public FitViewport getViewport() { + return viewport; + } + + public OrthographicCamera getCamera() { + return camera; + } + + public SpriteBatch getBatch() { + return batch; + } + + public Texture getBgTexture() { + return bgTexture; + } + + public boolean isMinimized() { + return isMinimized; + } + + /** + * Configurers Flixel's crash handler to safely catch uncaught exceptions and gracefully close the game. + */ + protected void configureCrashHandler() { + Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { + String logs = FlixelRuntimeUtil.getFullExceptionMessage(throwable); + String msg = "There was an uncaught exception on thread \"" + thread.getName() + "\"!\n" + logs; + Flixel.error(FlixelConstants.System.LOG_TAG, msg); + dispose(); + // Only use Gdx.app.exit() on non-iOS platforms to avoid App Store guideline violations! + if (Gdx.app.getType() != Application.ApplicationType.iOS) { + Gdx.app.exit(); + } + }); + } +} diff --git a/core/src/main/java/me/stringfromjava/funkin/backend/Paths.java b/core/src/main/java/me/stringfromjava/flixelgdx/backend/FlixelPaths.java similarity index 86% rename from core/src/main/java/me/stringfromjava/funkin/backend/Paths.java rename to core/src/main/java/me/stringfromjava/flixelgdx/backend/FlixelPaths.java index d406bab..193b68e 100644 --- a/core/src/main/java/me/stringfromjava/funkin/backend/Paths.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/backend/FlixelPaths.java @@ -1,10 +1,10 @@ -package me.stringfromjava.funkin.backend; +package me.stringfromjava.flixelgdx.backend; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; /** Utility class for simplifying asset paths and libGDX {@link FileHandle}s. */ -public final class Paths { +public final class FlixelPaths { public static FileHandle asset(String path) { return Gdx.files.internal(path); @@ -26,5 +26,5 @@ public static FileHandle external(String path) { return Gdx.files.external(path); } - private Paths() {} + private FlixelPaths() {} } diff --git a/core/src/main/java/me/stringfromjava/funkin/graphics/screen/FunkinScreen.java b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/screen/FlixelScreen.java similarity index 77% rename from core/src/main/java/me/stringfromjava/funkin/graphics/screen/FunkinScreen.java rename to core/src/main/java/me/stringfromjava/flixelgdx/graphics/screen/FlixelScreen.java index 69d390f..daa8efa 100644 --- a/core/src/main/java/me/stringfromjava/funkin/graphics/screen/FunkinScreen.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/screen/FlixelScreen.java @@ -1,21 +1,21 @@ -package me.stringfromjava.funkin.graphics.screen; +package me.stringfromjava.flixelgdx.graphics.screen; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.SnapshotArray; -import me.stringfromjava.funkin.graphics.sprite.FunkinObject; +import me.stringfromjava.flixelgdx.graphics.sprite.FlixelObject; /** * Base class for creating a better screen display with more functionality than the default {@link * com.badlogic.gdx.Screen} interface. */ -public abstract class FunkinScreen implements Screen { +public abstract class FlixelScreen implements Screen { /** The background color of {@code this} current screen. */ protected Color bgColor; /** All display objects that are shown in {@code this} screen. */ - public final SnapshotArray members = new SnapshotArray<>(FunkinObject.class); + public final SnapshotArray members = new SnapshotArray<>(FlixelObject.class); @Override public void show() {} @@ -44,7 +44,7 @@ public void dispose() {} * * @param object The sprite to add to the screen. */ - public void add(FunkinObject object) { + public void add(FlixelObject object) { if (object != null) { members.add(object); } diff --git a/core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelObject.java b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelObject.java new file mode 100644 index 0000000..2cf3d08 --- /dev/null +++ b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelObject.java @@ -0,0 +1,9 @@ +package me.stringfromjava.flixelgdx.graphics.sprite; + +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; + +/** + * An interface which allows any class that implements it to be added to a {@link + * FlixelScreen}. + */ +public interface FlixelObject {} diff --git a/core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinSprite.java b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelSprite.java similarity index 95% rename from core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinSprite.java rename to core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelSprite.java index deed5d3..c0bc65a 100644 --- a/core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinSprite.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/sprite/FlixelSprite.java @@ -1,4 +1,4 @@ -package me.stringfromjava.funkin.graphics.sprite; +package me.stringfromjava.flixelgdx.graphics.sprite; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Texture; @@ -21,7 +21,7 @@ * *

It allows you to load animations, textures, and do much more with simplicity and ease. */ -public class FunkinSprite extends Sprite implements FunkinObject, Pool.Poolable { +public class FlixelSprite extends Sprite implements FlixelObject, Pool.Poolable { /** The texture image that {@code this} sprite uses. */ protected Texture texture; @@ -53,7 +53,7 @@ public class FunkinSprite extends Sprite implements FunkinObject, Pool.Poolable */ protected TextureRegion[][] frames; - public FunkinSprite() { + public FlixelSprite() { animations = new HashMap<>(); } @@ -77,7 +77,7 @@ public void update(float delta) { * @param path The directory of the {@code .png} to load onto {@code this} sprite. * @return {@code this} sprite for chaining. */ - public FunkinSprite loadGraphic(FileHandle path) { + public FlixelSprite loadGraphic(FileHandle path) { Texture texture = new Texture(path); return loadGraphic(texture, texture.getWidth(), texture.getHeight()); } @@ -89,7 +89,7 @@ public FunkinSprite loadGraphic(FileHandle path) { * @param frameWidth How wide the sprite should be. * @return {@code this} sprite for chaining. */ - public FunkinSprite loadGraphic(FileHandle path, int frameWidth) { + public FlixelSprite loadGraphic(FileHandle path, int frameWidth) { Texture texture = new Texture(path); return loadGraphic(texture, frameWidth, texture.getHeight()); } @@ -102,11 +102,11 @@ public FunkinSprite loadGraphic(FileHandle path, int frameWidth) { * @param frameHeight How tall the sprite should be. * @return {@code this} sprite for chaining. */ - public FunkinSprite loadGraphic(FileHandle path, int frameWidth, int frameHeight) { + public FlixelSprite loadGraphic(FileHandle path, int frameWidth, int frameHeight) { return loadGraphic(new Texture(path), frameWidth, frameHeight); } - public FunkinSprite loadGraphic(Texture texture, int frameWidth, int frameHeight) { + public FlixelSprite loadGraphic(Texture texture, int frameWidth, int frameHeight) { frames = TextureRegion.split(texture, frameWidth, frameHeight); // Set default visual to the first frame. setRegion(frames[0][0]); @@ -124,7 +124,7 @@ public FunkinSprite loadGraphic(Texture texture, int frameWidth, int frameHeight * the sparrow atlas. * @return {@code this} sprite for chaining. */ - public FunkinSprite loadSparrowFrames(FileHandle texture, FileHandle xmlFile) { + public FlixelSprite loadSparrowFrames(FileHandle texture, FileHandle xmlFile) { return loadSparrowFrames(new Texture(texture), new XmlReader().parse(xmlFile)); } @@ -137,7 +137,7 @@ public FunkinSprite loadSparrowFrames(FileHandle texture, FileHandle xmlFile) { * of the sparrow atlas. * @return {@code this} sprite for chaining. */ - public FunkinSprite loadSparrowFrames(Texture texture, XmlReader.Element xmlFile) { + public FlixelSprite loadSparrowFrames(Texture texture, XmlReader.Element xmlFile) { // We store regions in a list so we can filter them by prefix later. // TextureAtlas.AtlasRegion is used because it supports offsets. atlasRegions = new Array<>(); diff --git a/core/src/main/java/me/stringfromjava/funkin/graphics/text/FunkinText.java b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/text/FlixelText.java similarity index 78% rename from core/src/main/java/me/stringfromjava/funkin/graphics/text/FunkinText.java rename to core/src/main/java/me/stringfromjava/flixelgdx/graphics/text/FlixelText.java index da42da5..138dbba 100644 --- a/core/src/main/java/me/stringfromjava/funkin/graphics/text/FunkinText.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/graphics/text/FlixelText.java @@ -1,7 +1,7 @@ -package me.stringfromjava.funkin.graphics.text; +package me.stringfromjava.flixelgdx.graphics.text; /** A display object for creating a piece of text to show on the screen. */ -public class FunkinText { +public class FlixelText { /** The text to be written onto the screen. */ public String text; @@ -15,7 +15,7 @@ public class FunkinText { /** * @param text The string to be displayed. */ - public FunkinText(String text) { + public FlixelText(String text) { this.text = text; x = 0; y = 0; diff --git a/core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignal.java b/core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignal.java similarity index 95% rename from core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignal.java rename to core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignal.java index 89d3af0..283cf0f 100644 --- a/core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignal.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignal.java @@ -1,4 +1,4 @@ -package me.stringfromjava.funkin.util.signal; +package me.stringfromjava.flixelgdx.signal; import java.util.concurrent.CopyOnWriteArrayList; @@ -6,12 +6,12 @@ * Utility class for creating objects that can execute multiple callbacks when it is dispatched (or * triggered). */ -public class FunkinSignal { +public class FlixelSignal { private final CopyOnWriteArrayList> callbacks; private final CopyOnWriteArrayList> tempCallbacks; // Callbacks that are added with addOnce(). - public FunkinSignal() { + public FlixelSignal() { callbacks = new CopyOnWriteArrayList<>(); tempCallbacks = new CopyOnWriteArrayList<>(); } diff --git a/core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignalData.java b/core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignalData.java new file mode 100644 index 0000000..466963d --- /dev/null +++ b/core/src/main/java/me/stringfromjava/flixelgdx/signal/FlixelSignalData.java @@ -0,0 +1,22 @@ +package me.stringfromjava.flixelgdx.signal; + +import games.rednblack.miniaudio.MASound; +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; +import me.stringfromjava.flixelgdx.Flixel; + +/** + * Convenience class for holding all signal data records used in the default signals stored in + * the global {@link Flixel} manager class. + */ +public final class FlixelSignalData { + + public record RenderSignalData(float delta) {} + + public record ScreenSwitchSignalData(FlixelScreen screen) {} + + public record SoundPlayedSignalData(MASound sound) {} + + public record MusicPlayedSignalData(MASound music) {} + + private FlixelSignalData() {} +} diff --git a/core/src/main/java/me/stringfromjava/funkin/tween/FunkinEase.java b/core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelEase.java similarity index 96% rename from core/src/main/java/me/stringfromjava/funkin/tween/FunkinEase.java rename to core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelEase.java index 5d89e43..170b26a 100644 --- a/core/src/main/java/me/stringfromjava/funkin/tween/FunkinEase.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelEase.java @@ -1,7 +1,7 @@ -package me.stringfromjava.funkin.tween; +package me.stringfromjava.flixelgdx.tween; /** Class where all easer functions are stored, mostly used for tweening. */ -public final class FunkinEase { +public final class FlixelEase { // Easing constants for specific functions. private static final float PI2 = (float) Math.PI / 2; @@ -15,7 +15,7 @@ public final class FunkinEase { private static final float ELASTIC_AMPLITUDE = 1; private static final float ELASTIC_PERIOD = 0.4f; - private FunkinEase() {} + private FlixelEase() {} public static float linear(float t) { return t; @@ -205,17 +205,17 @@ public interface FunkinEaseFunction { @FunctionalInterface public interface FunkinEaseStartCallback { - void run(FunkinTween tween); + void run(FlixelTween tween); } @FunctionalInterface public interface FunkinEaseUpdateCallback { - void run(FunkinTween tween); + void run(FlixelTween tween); } @FunctionalInterface public interface FunkinEaseCompleteCallback { - void run(FunkinTween tween); + void run(FlixelTween tween); } } diff --git a/core/src/main/java/me/stringfromjava/funkin/tween/FunkinTween.java b/core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelTween.java similarity index 84% rename from core/src/main/java/me/stringfromjava/funkin/tween/FunkinTween.java rename to core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelTween.java index 2f7b21c..4a9aba1 100644 --- a/core/src/main/java/me/stringfromjava/funkin/tween/FunkinTween.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelTween.java @@ -1,10 +1,10 @@ -package me.stringfromjava.funkin.tween; +package me.stringfromjava.flixelgdx.tween; import com.badlogic.gdx.utils.Pool; -import me.stringfromjava.funkin.Funkin; -import me.stringfromjava.funkin.tween.settings.FunkinTweenSettings; -import me.stringfromjava.funkin.util.Constants; -import me.stringfromjava.funkin.util.FunkinReflectUtil; +import me.stringfromjava.flixelgdx.Flixel; +import me.stringfromjava.flixelgdx.tween.settings.FlixelTweenSettings; +import me.stringfromjava.flixelgdx.util.FlixelConstants; +import me.stringfromjava.flixelgdx.util.FlixelReflectUtil; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -19,25 +19,25 @@ * *

Note that this doesn't have to be used on sprites, it can be used on just about anything! */ -public class FunkinTween implements Pool.Poolable { +public class FlixelTween implements Pool.Poolable { /** The global tween manager for the entire game. */ - protected static FunkinTweenManager globalManager = new FunkinTweenManager(); + protected static FlixelTweenManager globalManager = new FlixelTweenManager(); /** The object to tween. */ protected Object object; /** The settings used for how the tween is handled and calculated (aka how it looks and animates). */ - protected FunkinTweenSettings tweenSettings; + protected FlixelTweenSettings tweenSettings; /** The parent manager that {@code this} tween gets updated in. */ - protected FunkinTweenManager manager; + protected FlixelTweenManager manager; /** How far the tween is tweening itself. This is what's used to actually tween the object! */ protected float scale = 0.0f; /** The update callback for {@code this} tween to change the objects values every update. */ - protected FunkinTween.FunkinTweenUpdateCallback updateCallback; + protected FlixelTween.FunkinTweenUpdateCallback updateCallback; /** How many seconds has elapsed since {@code this} tween started. */ protected float secondsSinceStart = 0.0f; @@ -67,14 +67,14 @@ public class FunkinTween implements Pool.Poolable { protected Field[] fieldsCache = null; /** Default constructor for pooling purposes. */ - protected FunkinTween() {} + protected FlixelTween() {} /** * Constructs a new tween. * *

Note that this does NOT add the tween to the global manager, it just assigns its main * values. That's it. If you wish to create a tween to automatically start working, you might want - * to see {@link FunkinTween#tween(Object object, FunkinTweenSettings tweenSettings, + * to see {@link FlixelTween#tween(Object object, FlixelTweenSettings tweenSettings, * FunkinTweenUpdateCallback updateCallback)}. * * @param object The object to tween values. @@ -82,8 +82,8 @@ protected FunkinTween() {} * for. * @param updateCallback Callback function for updating the objects values when the tween updates. */ - protected FunkinTween( - Object object, FunkinTweenSettings settings, FunkinTweenUpdateCallback updateCallback) { + protected FlixelTween( + Object object, FlixelTweenSettings settings, FunkinTweenUpdateCallback updateCallback) { this.object = object; this.tweenSettings = settings; this.updateCallback = updateCallback; @@ -97,9 +97,9 @@ protected FunkinTween( * @param updateCallback Callback function for updating the objects values when the tween updates. * @return The newly created and started tween. */ - public static FunkinTween tween( - Object object, FunkinTweenSettings tweenSettings, FunkinTweenUpdateCallback updateCallback) { - return new FunkinTween(object, tweenSettings, updateCallback).setManager(globalManager).start(); + public static FlixelTween tween( + Object object, FlixelTweenSettings tweenSettings, FunkinTweenUpdateCallback updateCallback) { + return new FlixelTween(object, tweenSettings, updateCallback).setManager(globalManager).start(); } public void update(float delta) { @@ -154,7 +154,7 @@ public void update(float delta) { var newValues = new HashMap(); var goals = tweenSettings.getGoalFields(); for (String field : goals) { - FunkinTweenSettings.FunkinTweenGoal goal = tweenSettings.getGoal(field); + FlixelTweenSettings.FunkinTweenGoal goal = tweenSettings.getGoal(field); if (goal == null) { continue; } @@ -189,23 +189,23 @@ public void update(float delta) { * * @return {@code this} tween. */ - public FunkinTween start() { + public FlixelTween start() { resetBasic(); running = true; finished = false; if (tweenSettings == null) { - Funkin.warn("FunkinTween", "No tween settings were provided for the tween."); + Flixel.warn("FlixelTween", "No tween settings were provided for the tween."); return this; } var neededFields = tweenSettings.getGoalFields(); if (neededFields == null || neededFields.isEmpty()) { - Funkin.warn("FunkinTween", "No fields were provided to tween on the object."); + Flixel.warn("FlixelTween", "No fields were provided to tween on the object."); return this; } if (fieldsCache == null) { - fieldsCache = FunkinReflectUtil.getAllFieldsAsArray(object.getClass()); + fieldsCache = FlixelReflectUtil.getAllFieldsAsArray(object.getClass()); } // Ensure that the fields provided actually exist on the object and are floating point values. @@ -215,7 +215,7 @@ public FunkinTween start() { for (String neededField : neededFields) { if (!fieldIds.contains(neededField)) { String message = "Field \"" + neededField + "\" does not exist on the given object."; - Funkin.error("FunkinTween", message); + Flixel.error("FlixelTween", message); throw new RuntimeException(message); } } @@ -234,8 +234,8 @@ public FunkinTween start() { } initialValues.put(fName, field.getFloat(object)); } catch (IllegalAccessException e) { - Funkin.error( - Constants.System.LOG_TAG, "Could not access field \"" + field.getName() + "\".", e); + Flixel.error( + FlixelConstants.System.LOG_TAG, "Could not access field \"" + field.getName() + "\".", e); } } return this; @@ -246,7 +246,7 @@ public FunkinTween start() { * * @return {@code this} tween. */ - public FunkinTween resume() { + public FlixelTween resume() { paused = false; return this; } @@ -256,7 +256,7 @@ public FunkinTween resume() { * * @return {@code this} tween. */ - public FunkinTween pause() { + public FlixelTween pause() { paused = true; running = false; return this; @@ -268,7 +268,7 @@ public FunkinTween pause() { * * @return {@code this} tween. */ - public FunkinTween stop() { + public FlixelTween stop() { running = false; finished = true; return this; @@ -280,7 +280,7 @@ public FunkinTween stop() { * * @return {@code this} tween. */ - public FunkinTween cancel() { + public FlixelTween cancel() { return cancel(true); } @@ -290,7 +290,7 @@ public FunkinTween cancel() { * @param remove Should {@code this} tween be removed from its manager? * @return {@code this} tween. */ - public FunkinTween cancel(boolean remove) { + public FlixelTween cancel(boolean remove) { reset(); if (remove) { manager.getTweenPool().free(this); @@ -320,20 +320,20 @@ public void resetBasic() { initialValues.clear(); } - public FunkinTweenSettings getTweenSettings() { + public FlixelTweenSettings getTweenSettings() { return tweenSettings; } - public FunkinTween setTweenSettings(@NotNull FunkinTweenSettings tweenSettings) { + public FlixelTween setTweenSettings(@NotNull FlixelTweenSettings tweenSettings) { this.tweenSettings = tweenSettings; return this; } - public static FunkinTweenManager getGlobalManager() { + public static FlixelTweenManager getGlobalManager() { return globalManager; } - public FunkinTween setManager(FunkinTweenManager newManager) { + public FlixelTween setManager(FlixelTweenManager newManager) { if (newManager != null) { if (manager != null) { int index = manager.getActiveTweens().indexOf(this, true); diff --git a/core/src/main/java/me/stringfromjava/funkin/tween/FunkinTweenManager.java b/core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelTweenManager.java similarity index 70% rename from core/src/main/java/me/stringfromjava/funkin/tween/FunkinTweenManager.java rename to core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelTweenManager.java index a6c20e5..431f10e 100644 --- a/core/src/main/java/me/stringfromjava/funkin/tween/FunkinTweenManager.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/tween/FlixelTweenManager.java @@ -1,19 +1,19 @@ -package me.stringfromjava.funkin.tween; +package me.stringfromjava.flixelgdx.tween; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Pool; -/** Core manager class for handling all {@link FunkinTween}s that are currently active. */ -public class FunkinTweenManager { +/** Manager class for handling a list of active {@link FlixelTween}s. */ +public class FlixelTweenManager { /** Array where all current active tweens are stored. */ - protected final Array activeTweens = new Array<>(FunkinTween.class); + protected final Array activeTweens = new Array<>(FlixelTween.class); /** A pool where all unused tweens are stored to preserve memory. */ - protected final Pool tweenPool = new Pool<>() { + protected final Pool tweenPool = new Pool<>() { @Override - protected FunkinTween newObject() { - return new FunkinTween(); + protected FlixelTween newObject() { + return new FlixelTween(); } }; @@ -50,11 +50,11 @@ public void update(float delta) { } } - public Array getActiveTweens() { + public Array getActiveTweens() { return activeTweens; } - public Pool getTweenPool() { + public Pool getTweenPool() { return tweenPool; } } diff --git a/core/src/main/java/me/stringfromjava/funkin/tween/settings/FunkinTweenSettings.java b/core/src/main/java/me/stringfromjava/flixelgdx/tween/settings/FlixelTweenSettings.java similarity index 66% rename from core/src/main/java/me/stringfromjava/funkin/tween/settings/FunkinTweenSettings.java rename to core/src/main/java/me/stringfromjava/flixelgdx/tween/settings/FlixelTweenSettings.java index 554cd2a..17598b2 100644 --- a/core/src/main/java/me/stringfromjava/funkin/tween/settings/FunkinTweenSettings.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/tween/settings/FlixelTweenSettings.java @@ -1,6 +1,7 @@ -package me.stringfromjava.funkin.tween.settings; +package me.stringfromjava.flixelgdx.tween.settings; -import me.stringfromjava.funkin.tween.FunkinEase; +import me.stringfromjava.flixelgdx.tween.FlixelTween; +import me.stringfromjava.flixelgdx.tween.FlixelEase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -10,39 +11,39 @@ /** * Class for holding basic data, containing configurations to be used on a {@link - * me.stringfromjava.funkin.tween.FunkinTween}. + * FlixelTween}. */ -public class FunkinTweenSettings { +public class FlixelTweenSettings { private float duration; private float startDelay; private float loopDelay; private float framerate; - private FunkinTweenType type; - private FunkinEase.FunkinEaseFunction ease; - private FunkinEase.FunkinEaseStartCallback onStart; - private FunkinEase.FunkinEaseUpdateCallback onUpdate; - private FunkinEase.FunkinEaseCompleteCallback onComplete; + private FlixelTweenType type; + private FlixelEase.FunkinEaseFunction ease; + private FlixelEase.FunkinEaseStartCallback onStart; + private FlixelEase.FunkinEaseUpdateCallback onUpdate; + private FlixelEase.FunkinEaseCompleteCallback onComplete; private ArrayList goals; - public FunkinTweenSettings() { - this(FunkinTweenType.ONESHOT, FunkinEase::linear); + public FlixelTweenSettings() { + this(FlixelTweenType.ONESHOT, FlixelEase::linear); } /** * @param type The type of tween it should be. */ - public FunkinTweenSettings(@NotNull FunkinTweenType type) { - this(type, FunkinEase::linear); + public FlixelTweenSettings(@NotNull FlixelTweenType type) { + this(type, FlixelEase::linear); } /** * @param type The type of tween it should be. * @param ease The easer function the tween should use (aka how it should be animated). */ - public FunkinTweenSettings( - @NotNull FunkinTweenType type, - @Nullable FunkinEase.FunkinEaseFunction ease) { + public FlixelTweenSettings( + @NotNull FlixelTweenType type, + @Nullable FlixelEase.FunkinEaseFunction ease) { this.duration = 1.0f; this.startDelay = 0.0f; this.loopDelay = 0.0f; @@ -62,7 +63,7 @@ public FunkinTweenSettings( * @param value The value to tween the field to. * @return {@code this} tween settings object for chaining. */ - public FunkinTweenSettings addGoal(String field, float value) { + public FlixelTweenSettings addGoal(String field, float value) { goals.add(new FunkinTweenGoal(field, value)); return this; } @@ -73,7 +74,7 @@ public FunkinTweenSettings addGoal(String field, float value) { * @param duration The new value to set. * @return {@code this} tween settings object for chaining. */ - public FunkinTweenSettings setDuration(float duration) { + public FlixelTweenSettings setDuration(float duration) { this.duration = duration; return this; } @@ -82,23 +83,23 @@ public float getDuration() { return duration; } - public FunkinTweenType getType() { + public FlixelTweenType getType() { return type; } - public FunkinEase.FunkinEaseFunction getEase() { + public FlixelEase.FunkinEaseFunction getEase() { return ease; } - public FunkinEase.FunkinEaseStartCallback getOnStart() { + public FlixelEase.FunkinEaseStartCallback getOnStart() { return onStart; } - public FunkinEase.FunkinEaseUpdateCallback getOnUpdate() { + public FlixelEase.FunkinEaseUpdateCallback getOnUpdate() { return onUpdate; } - public FunkinEase.FunkinEaseCompleteCallback getOnComplete() { + public FlixelEase.FunkinEaseCompleteCallback getOnComplete() { return onComplete; } @@ -135,7 +136,7 @@ public float getFramerate() { return framerate; } - public FunkinTweenSettings setEase(FunkinEase.FunkinEaseFunction ease) { + public FlixelTweenSettings setEase(FlixelEase.FunkinEaseFunction ease) { this.ease = ease; return this; } @@ -144,22 +145,22 @@ public void clearGoals() { goals.clear(); } - public FunkinTweenSettings setStartDelay(float startDelay) { + public FlixelTweenSettings setStartDelay(float startDelay) { this.startDelay = startDelay; return this; } - public FunkinTweenSettings setLoopDelay(float loopDelay) { + public FlixelTweenSettings setLoopDelay(float loopDelay) { this.loopDelay = loopDelay; return this; } - public FunkinTweenSettings setFramerate(float framerate) { + public FlixelTweenSettings setFramerate(float framerate) { this.framerate = framerate; return this; } - public FunkinTweenSettings setType(@NotNull FunkinTweenType type) { + public FlixelTweenSettings setType(@NotNull FlixelTweenType type) { this.type = type; return this; } diff --git a/core/src/main/java/me/stringfromjava/funkin/tween/settings/FunkinTweenType.java b/core/src/main/java/me/stringfromjava/flixelgdx/tween/settings/FlixelTweenType.java similarity index 84% rename from core/src/main/java/me/stringfromjava/funkin/tween/settings/FunkinTweenType.java rename to core/src/main/java/me/stringfromjava/flixelgdx/tween/settings/FlixelTweenType.java index e5bf801..4dbcb34 100644 --- a/core/src/main/java/me/stringfromjava/funkin/tween/settings/FunkinTweenType.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/tween/settings/FlixelTweenType.java @@ -1,7 +1,7 @@ -package me.stringfromjava.funkin.tween.settings; +package me.stringfromjava.flixelgdx.tween.settings; /** Enum containing all different tween types that can determine */ -public enum FunkinTweenType { +public enum FlixelTweenType { /** Will stop and remove itself from the manager when it finishes. */ ONESHOT, diff --git a/core/src/main/java/me/stringfromjava/funkin/util/Constants.java b/core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelConstants.java similarity index 61% rename from core/src/main/java/me/stringfromjava/funkin/util/Constants.java rename to core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelConstants.java index d5d04db..5b1f95f 100644 --- a/core/src/main/java/me/stringfromjava/funkin/util/Constants.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelConstants.java @@ -1,32 +1,14 @@ -package me.stringfromjava.funkin.util; +package me.stringfromjava.flixelgdx.util; /** * Core class for holding static classes with values which do not change. It is NOT RECOMMENDED to * store things like {@link java.util.ArrayList}'s, as they can still be modified even if they are * initialized as {@code final}. */ -public final class Constants { - - /** Holds values for aspects of the game's display, such as the window's width and height. */ - public static final class Display { - - /** - * How wide the window's viewport is in pixels. This also affects how wide the window is when - * the game first starts up. - */ - public static final int WINDOW_WIDTH = 1280; - - /** - * How tall the window's viewport is in pixels. This also affects how tall the window is when - * the game first starts up. - */ - public static final int WINDOW_HEIGHT = 720; - - private Display() {} - } +public final class FlixelConstants { /** - * Stores constants for things related to the backend of Funkin'. This includes components like + * Stores constants for things related to the backend of Flixel. This includes components like * logging, folder paths, etc. */ public static final class System { @@ -35,7 +17,7 @@ public static final class System { * The default and globally recognized default tag for logs that are outputted inside the * console. */ - public static final String LOG_TAG = "Funkin"; + public static final String LOG_TAG = "Flixel"; private System() {} } diff --git a/core/src/main/java/me/stringfromjava/funkin/util/FunkinReflectUtil.java b/core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelReflectUtil.java similarity index 90% rename from core/src/main/java/me/stringfromjava/funkin/util/FunkinReflectUtil.java rename to core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelReflectUtil.java index ec53a0d..bef7dda 100644 --- a/core/src/main/java/me/stringfromjava/funkin/util/FunkinReflectUtil.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelReflectUtil.java @@ -1,6 +1,6 @@ -package me.stringfromjava.funkin.util; +package me.stringfromjava.flixelgdx.util; -import me.stringfromjava.funkin.Funkin; +import me.stringfromjava.flixelgdx.Flixel; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -13,7 +13,7 @@ * Backend utility class for obtaining and manipulating fields on objects through the usage of Java * reflection. */ -public class FunkinReflectUtil { +public class FlixelReflectUtil { /** * Checks if a field exists on a given object. @@ -65,7 +65,7 @@ public static Field[] getAllFieldsAsArray(Class type) { * Checks if a class of a certain package is final. * * @param classPath The package definition of the class to check if final. An example could be - * {@code "me.stringfromjava.funkin.Funkin"}. + * {@code "me.stringfromjava.flixelgdx.Flixel"}. * @return If the class provided is final. If there was an exception caught, then {@code false} is * automatically returned. */ @@ -77,7 +77,7 @@ public static boolean isClassFinal(String classPath) { } catch (ClassNotFoundException e) { // Treat non-existent class as non-final for safe binding, // though the user will hit an error later. - Funkin.error(Constants.System.LOG_TAG, "Failed to check if a class was final.", e); + Flixel.error(FlixelConstants.System.LOG_TAG, "Failed to check if a class was final.", e); return false; } } diff --git a/core/src/main/java/me/stringfromjava/funkin/util/FunkinRuntimeUtil.java b/core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelRuntimeUtil.java similarity index 92% rename from core/src/main/java/me/stringfromjava/funkin/util/FunkinRuntimeUtil.java rename to core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelRuntimeUtil.java index 6ab4507..2ce8b95 100644 --- a/core/src/main/java/me/stringfromjava/funkin/util/FunkinRuntimeUtil.java +++ b/core/src/main/java/me/stringfromjava/flixelgdx/util/FlixelRuntimeUtil.java @@ -1,10 +1,10 @@ -package me.stringfromjava.funkin.util; +package me.stringfromjava.flixelgdx.util; /** * Utility class for handling operation related to the runtime environment, including OS detection, * extracting runtime information, obtaining information from exceptions, and other related tasks. */ -public final class FunkinRuntimeUtil { +public final class FlixelRuntimeUtil { /** * Obtains a string representation of where an exception was thrown from, including the class, @@ -33,8 +33,7 @@ public static String getExceptionLocation(Throwable exception) { } /** - * Obtains a full detailed message from an exception, including its type, location, and stack - * trace. + * Obtains a full detailed message from an exception, including its type, location, and stack trace. * * @param exception The exception to obtain the message from. * @return A full detailed message from the exception. @@ -53,5 +52,5 @@ public static String getFullExceptionMessage(Throwable exception) { return messageBuilder.toString(); } - private FunkinRuntimeUtil() {} + private FlixelRuntimeUtil() {} } diff --git a/core/src/main/java/me/stringfromjava/funkin/FunkinGame.java b/core/src/main/java/me/stringfromjava/funkin/FunkinGame.java index f892d80..1d93000 100644 --- a/core/src/main/java/me/stringfromjava/funkin/FunkinGame.java +++ b/core/src/main/java/me/stringfromjava/funkin/FunkinGame.java @@ -1,224 +1,33 @@ package me.stringfromjava.funkin; -import com.badlogic.gdx.Application; -import com.badlogic.gdx.ApplicationListener; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Input; -import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.OrthographicCamera; -import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.utils.ScreenUtils; -import com.badlogic.gdx.utils.viewport.FitViewport; -import me.stringfromjava.funkin.backend.Paths; -import me.stringfromjava.funkin.game.InitScreen; -import me.stringfromjava.funkin.graphics.screen.FunkinScreen; -import me.stringfromjava.funkin.graphics.sprite.FunkinObject; -import me.stringfromjava.funkin.graphics.sprite.FunkinSprite; -import me.stringfromjava.funkin.polyverse.Polyverse; -import me.stringfromjava.funkin.polyverse.script.type.Script; -import me.stringfromjava.funkin.polyverse.script.type.SystemScript; -import me.stringfromjava.funkin.tween.FunkinTween; -import me.stringfromjava.funkin.util.Constants; -import me.stringfromjava.funkin.util.FunkinRuntimeUtil; - -import static me.stringfromjava.funkin.util.signal.FunkinSignalData.RenderSignalData; +import me.stringfromjava.flixelgdx.Flixel; +import me.stringfromjava.flixelgdx.FlixelGame; +import me.stringfromjava.flixelgdx.backend.FlixelPaths; +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; +import me.stringfromjava.polyverse.Polyverse; +import me.stringfromjava.polyverse.script.type.Script; +import me.stringfromjava.polyverse.script.type.SystemScript; /** - * The game object used for containing the main loop and core elements of Funkin'. - * - *

If you want to change what happens to the pre and window configurations, you might want to see - * {@code Lwjgl3Launcher} in the {@code lwjgl3} folder. + * The main Funkin' game class that initializes and runs the game. */ -public class FunkinGame implements ApplicationListener { - - /** Is the game's window currently minimized? */ - protected boolean isMinimized = false; - - /** The main stage used for rendering all screens and sprites on screen. */ - protected Stage stage; - - /** The main viewport used to fit the world no matter the screen size. */ - protected FitViewport viewport; - - /** The main camera used to see the world. */ - protected OrthographicCamera camera; - - /** The main sprite batch used for rendering all sprites on screen. */ - protected SpriteBatch batch; +public class FunkinGame extends FlixelGame { - /** The 1x1 texture used to draw the background color of the current screen. */ - protected Texture bgTexture; - - @Override - public void create() { - configureCrashHandler(); // Crash handler for uncaught exceptions. - configureWindow(); // Window and viewport. - configurePolyverse(); // Polyverse scripting and modding system. - Funkin.setScreen(new InitScreen()); + public FunkinGame(String title, int width, int height, FlixelScreen initialScreen) { + super(title, width, height, initialScreen); } @Override - public void resize(int width, int height) { - viewport.update(width, height, true); + public void create() { + super.create(); + configurePolyverse(); // Scripting and modding support. } @Override public void render() { - float delta = Gdx.graphics.getDeltaTime(); - FunkinScreen screen = Funkin.getScreen(); - - Funkin.Signals.preRender.dispatch(new RenderSignalData(delta)); - - if (Funkin.keyJustPressed(Input.Keys.F11)) { - toggleFullscreen(); - } - - // Update and render the current screen that's active. - ScreenUtils.clear(Color.BLACK); - viewport.apply(); - batch.setProjectionMatrix(camera.combined); - batch.begin(); - - if (screen != null) { - batch.setColor(screen.getBgColor()); - batch.draw(bgTexture, 0, 0, viewport.getWorldWidth(), viewport.getWorldHeight()); - batch.setColor(Color.WHITE); // Set color back to white so display objects aren't affected. - screen.render(delta); - var members = screen.members.begin(); - for (FunkinObject object : members) { - if (object instanceof FunkinSprite sprite) { - sprite.update(delta); - sprite.draw(batch); - } - } - screen.members.end(); - } - - batch.end(); - stage.act(delta); - stage.draw(); - - FunkinTween.getGlobalManager().update(delta); - Polyverse.forAllScripts(script -> script.onRender(delta)); - - Funkin.Signals.postRender.dispatch(new RenderSignalData(delta)); - } - - @Override - public void pause() {} - - @Override - public void resume() {} - - /** Called when the user regains focus on the game's window. */ - public void onWindowFocused() { - Funkin.setMasterVolume(1); - Funkin.Signals.windowFocused.dispatch(); - Funkin.info("Game window has regained focus."); - } - - /** Called when the user loses focus on the game's window, while also not being minimized. */ - public void onWindowUnfocused() { - if (isMinimized) { - return; - } - Funkin.setMasterVolume(0.008f); - Funkin.Signals.windowUnfocused.dispatch(); - Funkin.info("Game window has lost focus."); - } - - /** - * Called when the user minimizes the game's window. - * - * @param iconified Whether the window is iconified (minimized) or not. This parameter is provided - * for compatibility with the window listener in the LWJGL3 (desktop) launcher. - */ - public void onWindowMinimized(boolean iconified) { - isMinimized = iconified; - if (!isMinimized) { - return; - } - Funkin.setMasterVolume(0); - Funkin.Signals.windowMinimized.dispatch(); - Funkin.info("Game window has been minimized."); - } - - /** Toggles fullscreen mode on or off, depending on the current state. */ - public void toggleFullscreen() { - boolean isFullscreen = Gdx.graphics.isFullscreen(); - if (isFullscreen) { - Gdx.graphics.setWindowedMode(Constants.Display.WINDOW_WIDTH, Constants.Display.WINDOW_HEIGHT); - Funkin.info("Exiting fullscreen mode."); - } else { - Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); - Funkin.info("Entering fullscreen mode."); - } - } - - @Override - public void dispose() { - Funkin.warn("SHUTTING DOWN GAME AND DISPOSING ALL RESOURCES."); - - Funkin.Signals.preGameClose.dispatch(); - - Funkin.info("Disposing the screen display..."); - Funkin.getScreen().hide(); - Funkin.getScreen().dispose(); - stage.dispose(); - batch.dispose(); - bgTexture.dispose(); - - Funkin.info("Disposing all sounds from sound group and music..."); - if (Funkin.getMusic() != null) { - Funkin.getMusic().dispose(); - } - Funkin.getSoundsGroup().dispose(); - Funkin.getAudioEngine().dispose(); - - Funkin.info("Disposing and shutting down scripts..."); - Polyverse.forAllScripts(Script::onDispose); - - Funkin.Signals.postGameClose.dispatch(); - } - - public boolean isMinimized() { - return isMinimized; - } - - private void configureCrashHandler() { - Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> { - String logs = FunkinRuntimeUtil.getFullExceptionMessage(throwable); - String msg = "There was an uncaught exception on thread \"" + thread.getName() + "\"!\n" + logs; - Funkin.error(Constants.System.LOG_TAG, msg); - dispose(); - // Only use Gdx.app.exit() on non-iOS platforms to avoid App Store guideline violations! - if (Gdx.app.getType() != Application.ApplicationType.iOS) { - Gdx.app.exit(); - } - }); - } - - private void configureWindow() { - var wWidth = Constants.Display.WINDOW_WIDTH; - var wHeight = Constants.Display.WINDOW_HEIGHT; - - batch = new SpriteBatch(); - viewport = new FitViewport(wWidth, wHeight); - viewport.apply(); - - camera = new OrthographicCamera(); - camera.setToOrtho(false, wWidth, wHeight); - - stage = new Stage(viewport, batch); + super.render(); - Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); - pixmap.setColor(Color.WHITE); - pixmap.fill(); - bgTexture = new Texture(pixmap); - pixmap.dispose(); + Polyverse.forAllScripts(script -> script.onRender(Flixel.getDelta())); } private void configurePolyverse() { @@ -226,7 +35,7 @@ private void configurePolyverse() { Polyverse.registerScriptType(Script.class); // Master type, DO NOT REMOVE THIS! Polyverse.registerScriptType(SystemScript.class); - Polyverse.registerScript(Paths.asset("test.groovy")); - Polyverse.registerScript(Paths.asset("another_test.groovy")); + Polyverse.registerScript(FlixelPaths.asset("test.groovy")); + Polyverse.registerScript(FlixelPaths.asset("another_test.groovy")); } } diff --git a/core/src/main/java/me/stringfromjava/funkin/game/InitScreen.java b/core/src/main/java/me/stringfromjava/funkin/game/InitScreen.java deleted file mode 100644 index 6f67f69..0000000 --- a/core/src/main/java/me/stringfromjava/funkin/game/InitScreen.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.stringfromjava.funkin.game; - -import me.stringfromjava.funkin.Funkin; -import me.stringfromjava.funkin.game.menus.TitleScreen; -import me.stringfromjava.funkin.graphics.screen.FunkinScreen; - -public class InitScreen extends FunkinScreen { - - @Override - public void show() { - super.show(); - Funkin.setScreen(new TitleScreen()); - } -} diff --git a/core/src/main/java/me/stringfromjava/funkin/game/menus/TitleScreen.java b/core/src/main/java/me/stringfromjava/funkin/game/menus/TitleScreen.java deleted file mode 100644 index ab95517..0000000 --- a/core/src/main/java/me/stringfromjava/funkin/game/menus/TitleScreen.java +++ /dev/null @@ -1,90 +0,0 @@ -package me.stringfromjava.funkin.game.menus; - -import com.badlogic.gdx.Input; -import games.rednblack.miniaudio.MASound; -import me.stringfromjava.funkin.Funkin; -import me.stringfromjava.funkin.backend.Paths; -import me.stringfromjava.funkin.graphics.screen.FunkinScreen; -import me.stringfromjava.funkin.graphics.sprite.FunkinSprite; -import me.stringfromjava.funkin.tween.FunkinEase; -import me.stringfromjava.funkin.tween.FunkinTween; -import me.stringfromjava.funkin.tween.settings.FunkinTweenSettings; -import me.stringfromjava.funkin.tween.settings.FunkinTweenType; - -public class TitleScreen extends FunkinScreen { - - private FunkinSprite logo; - - private FunkinTween tween; - private MASound tickleFight; - - @Override - public void show() { - super.show(); - - var t = Paths.sharedImageAsset("noteStrumline"); - var xml = Paths.shared("images/noteStrumline.xml"); - logo = new FunkinSprite().loadSparrowFrames(t, xml); - logo.addAnimationByPrefix("test", "confirmDown", 24, false); - add(logo); - - tickleFight = Funkin.playSound("shared/sounds/tickleFight.ogg"); -// Funkin.playMusic("preload/music/freakyMenu/freakyMenu.ogg", 0.5f); - - FunkinTweenSettings settings = new FunkinTweenSettings() - .addGoal("x", 600) - .addGoal("y", 40) - .addGoal("rotation", 180) - .setDuration(0.7f) - .setEase(FunkinEase::circInOut) - .setType(FunkinTweenType.PERSIST); - tween = FunkinTween.tween(logo, settings, values -> { - logo.setX(values.get("x")); - logo.setY(values.get("y")); - logo.setRotation(values.get("rotation")); - }).stop(); - } - - @Override - public void render(float elapsed) { - super.render(elapsed); - - float speed = 500 * elapsed; - if (Funkin.keyPressed(Input.Keys.W)) { - logo.setY(logo.getY() + speed); - } - if (Funkin.keyPressed(Input.Keys.S)) { - logo.setY(logo.getY() - speed); - } - if (Funkin.keyPressed(Input.Keys.A)) { - logo.setX(logo.getX() - speed); - } - if (Funkin.keyPressed(Input.Keys.D)) { - logo.setX(logo.getX() + speed); - } - - if (Funkin.keyJustPressed(Input.Keys.SPACE)) { - logo.playAnimation("test", true); - } - - if (Funkin.keyJustPressed(Input.Keys.T)) { - tween.start(); - } - - if (Funkin.keyJustPressed(Input.Keys.R)) { - tween.reset(); - } - - if (Funkin.keyJustPressed(Input.Keys.Y)) { - if (tween.paused) { - tween.resume(); - } else { - tween.pause(); - } - } - - if (Funkin.keyJustPressed(Input.Keys.Z)) { - tickleFight.play(); - } - } -} diff --git a/core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinObject.java b/core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinObject.java deleted file mode 100644 index f7ee545..0000000 --- a/core/src/main/java/me/stringfromjava/funkin/graphics/sprite/FunkinObject.java +++ /dev/null @@ -1,7 +0,0 @@ -package me.stringfromjava.funkin.graphics.sprite; - -/** - * An interface which allows any class that implements it to be added to a {@link - * me.stringfromjava.funkin.graphics.screen.FunkinScreen}. - */ -public interface FunkinObject {} diff --git a/core/src/main/java/me/stringfromjava/funkin/init/InitScreen.java b/core/src/main/java/me/stringfromjava/funkin/init/InitScreen.java new file mode 100644 index 0000000..1f89de2 --- /dev/null +++ b/core/src/main/java/me/stringfromjava/funkin/init/InitScreen.java @@ -0,0 +1,14 @@ +package me.stringfromjava.funkin.init; + +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; +import me.stringfromjava.flixelgdx.Flixel; +import me.stringfromjava.funkin.menus.TitleScreen; + +public class InitScreen extends FlixelScreen { + + @Override + public void show() { + super.show(); + Flixel.setScreen(new TitleScreen()); + } +} diff --git a/core/src/main/java/me/stringfromjava/funkin/menus/TitleScreen.java b/core/src/main/java/me/stringfromjava/funkin/menus/TitleScreen.java new file mode 100644 index 0000000..bd6715d --- /dev/null +++ b/core/src/main/java/me/stringfromjava/funkin/menus/TitleScreen.java @@ -0,0 +1,90 @@ +package me.stringfromjava.funkin.menus; + +import com.badlogic.gdx.Input; +import games.rednblack.miniaudio.MASound; +import me.stringfromjava.flixelgdx.Flixel; +import me.stringfromjava.flixelgdx.backend.FlixelPaths; +import me.stringfromjava.flixelgdx.graphics.screen.FlixelScreen; +import me.stringfromjava.flixelgdx.graphics.sprite.FlixelSprite; +import me.stringfromjava.flixelgdx.tween.FlixelEase; +import me.stringfromjava.flixelgdx.tween.FlixelTween; +import me.stringfromjava.flixelgdx.tween.settings.FlixelTweenSettings; +import me.stringfromjava.flixelgdx.tween.settings.FlixelTweenType; + +public class TitleScreen extends FlixelScreen { + + private FlixelSprite logo; + + private FlixelTween tween; + private MASound tickleFight; + + @Override + public void show() { + super.show(); + + var t = FlixelPaths.sharedImageAsset("noteStrumline"); + var xml = FlixelPaths.shared("images/noteStrumline.xml"); + logo = new FlixelSprite().loadSparrowFrames(t, xml); + logo.addAnimationByPrefix("test", "confirmDown", 24, false); + add(logo); + + tickleFight = Flixel.playSound("shared/sounds/tickleFight.ogg"); +// Flixel.playMusic("preload/music/freakyMenu/freakyMenu.ogg", 0.5f); + + FlixelTweenSettings settings = new FlixelTweenSettings() + .addGoal("x", 600) + .addGoal("y", 40) + .addGoal("rotation", 180) + .setDuration(0.7f) + .setEase(FlixelEase::circInOut) + .setType(FlixelTweenType.PERSIST); + tween = FlixelTween.tween(logo, settings, values -> { + logo.setX(values.get("x")); + logo.setY(values.get("y")); + logo.setRotation(values.get("rotation")); + }).stop(); + } + + @Override + public void render(float elapsed) { + super.render(elapsed); + + float speed = 500 * elapsed; + if (Flixel.keyPressed(Input.Keys.W)) { + logo.setY(logo.getY() + speed); + } + if (Flixel.keyPressed(Input.Keys.S)) { + logo.setY(logo.getY() - speed); + } + if (Flixel.keyPressed(Input.Keys.A)) { + logo.setX(logo.getX() - speed); + } + if (Flixel.keyPressed(Input.Keys.D)) { + logo.setX(logo.getX() + speed); + } + + if (Flixel.keyJustPressed(Input.Keys.SPACE)) { + logo.playAnimation("test", true); + } + + if (Flixel.keyJustPressed(Input.Keys.T)) { + tween.start(); + } + + if (Flixel.keyJustPressed(Input.Keys.R)) { + tween.reset(); + } + + if (Flixel.keyJustPressed(Input.Keys.Y)) { + if (tween.paused) { + tween.resume(); + } else { + tween.pause(); + } + } + + if (Flixel.keyJustPressed(Input.Keys.Z)) { + tickleFight.play(); + } + } +} diff --git a/core/src/main/java/me/stringfromjava/funkin/util/FunkinConstants.java b/core/src/main/java/me/stringfromjava/funkin/util/FunkinConstants.java new file mode 100644 index 0000000..ced76f0 --- /dev/null +++ b/core/src/main/java/me/stringfromjava/funkin/util/FunkinConstants.java @@ -0,0 +1,26 @@ +package me.stringfromjava.funkin.util; + +/** + * Constants used throughout Funkin'. + */ +public final class FunkinConstants { + + /** + * The default title for the game's window. + */ + public static final String WINDOW_TITLE = "Friday Night Funkin': Java Edition"; + + /** + * How wide the window's viewport is in pixels. This also affects how wide the window is when + * the game first starts up. + */ + public static final int WINDOW_WIDTH = 1280; + + /** + * How tall the window's viewport is in pixels. This also affects how tall the window is when + * the game first starts up. + */ + public static final int WINDOW_HEIGHT = 720; + + private FunkinConstants() {} +} diff --git a/core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignalData.java b/core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignalData.java deleted file mode 100644 index 93f71ad..0000000 --- a/core/src/main/java/me/stringfromjava/funkin/util/signal/FunkinSignalData.java +++ /dev/null @@ -1,32 +0,0 @@ -package me.stringfromjava.funkin.util.signal; - -import games.rednblack.miniaudio.MASound; -import me.stringfromjava.funkin.graphics.screen.FunkinScreen; - -/** - * Convenience class for holding all signal data records used in the default signals stored in - * the global {@link me.stringfromjava.funkin.Funkin} manager class. - */ -public final class FunkinSignalData { - - public record RenderSignalData(float delta) { - - } - - public record ScreenSwitchSignalData(FunkinScreen screen) { - - } - - public record SoundPlayedSignalData(MASound sound) { - - } - - public record MusicPlayedSignalData(MASound music) { - - } - - private FunkinSignalData() { - } - -} - diff --git a/core/src/main/java/me/stringfromjava/funkin/polyverse/Polyverse.java b/core/src/main/java/me/stringfromjava/polyverse/Polyverse.java similarity index 91% rename from core/src/main/java/me/stringfromjava/funkin/polyverse/Polyverse.java rename to core/src/main/java/me/stringfromjava/polyverse/Polyverse.java index 81c746c..6daace4 100644 --- a/core/src/main/java/me/stringfromjava/funkin/polyverse/Polyverse.java +++ b/core/src/main/java/me/stringfromjava/polyverse/Polyverse.java @@ -1,9 +1,9 @@ -package me.stringfromjava.funkin.polyverse; +package me.stringfromjava.polyverse; import com.badlogic.gdx.files.FileHandle; import groovy.lang.GroovyClassLoader; -import me.stringfromjava.funkin.Funkin; -import me.stringfromjava.funkin.polyverse.script.type.Script; +import me.stringfromjava.flixelgdx.Flixel; +import me.stringfromjava.polyverse.script.type.Script; import java.util.ArrayList; import java.util.Collections; @@ -12,7 +12,7 @@ import java.util.Map; import java.util.function.Consumer; -/** Core manager class for managing the Polyverse mod engine for FNF:JE. */ +/** Core manager class for managing the Polyverse scripting and modding engine. */ public final class Polyverse { /** A map that stores lists of scripts based on their parent class type. */ @@ -81,7 +81,7 @@ public static void registerScript(FileHandle handle) { var typeScripts = scripts.get(mostSpecificType); if (!typeScripts.contains(script)) { typeScripts.add(script); - Funkin.info( + Flixel.info( "Polyverse", "Registered Polyverse script \"" + script.getClass().getSimpleName() @@ -93,14 +93,14 @@ public static void registerScript(FileHandle handle) { script.onCreate(); } } catch (Exception e) { - Funkin.error("Polyverse", "Failed to load script: " + handle.path(), e); + Flixel.error("Polyverse", "Failed to load script: " + handle.path(), e); } } /** * Executes an action for each script of a certain type, with error handling. * - * @param type The class type of scripts to iterate over. + * @param type The class type of scripts to iterate over. * @param action The action to perform on each script. */ public static void forEachScript(Class type, Consumer action) { @@ -132,7 +132,7 @@ private static void executeScriptList( try { action.accept(script); } catch (Exception e) { - Funkin.error("Polyverse", "Error in " + script.getClass().getSimpleName(), e); + Flixel.error("Polyverse", "Error in " + script.getClass().getSimpleName(), e); } } } diff --git a/core/src/main/java/me/stringfromjava/funkin/polyverse/script/type/Script.java b/core/src/main/java/me/stringfromjava/polyverse/script/type/Script.java similarity index 91% rename from core/src/main/java/me/stringfromjava/funkin/polyverse/script/type/Script.java rename to core/src/main/java/me/stringfromjava/polyverse/script/type/Script.java index 8effbbb..64d3ae7 100644 --- a/core/src/main/java/me/stringfromjava/funkin/polyverse/script/type/Script.java +++ b/core/src/main/java/me/stringfromjava/polyverse/script/type/Script.java @@ -1,4 +1,4 @@ -package me.stringfromjava.funkin.polyverse.script.type; +package me.stringfromjava.polyverse.script.type; /** Base class for all Polyverse scripts to extend to. */ public abstract class Script { diff --git a/core/src/main/java/me/stringfromjava/funkin/polyverse/script/type/SystemScript.java b/core/src/main/java/me/stringfromjava/polyverse/script/type/SystemScript.java similarity index 66% rename from core/src/main/java/me/stringfromjava/funkin/polyverse/script/type/SystemScript.java rename to core/src/main/java/me/stringfromjava/polyverse/script/type/SystemScript.java index de43ac7..b37a5e0 100644 --- a/core/src/main/java/me/stringfromjava/funkin/polyverse/script/type/SystemScript.java +++ b/core/src/main/java/me/stringfromjava/polyverse/script/type/SystemScript.java @@ -1,4 +1,4 @@ -package me.stringfromjava.funkin.polyverse.script.type; +package me.stringfromjava.polyverse.script.type; public abstract class SystemScript extends Script { diff --git a/lwjgl3/src/main/java/me/stringfromjava/funkin/lwjgl3/Lwjgl3Launcher.java b/lwjgl3/src/main/java/me/stringfromjava/funkin/lwjgl3/Lwjgl3Launcher.java index a5968d9..cef9ed3 100644 --- a/lwjgl3/src/main/java/me/stringfromjava/funkin/lwjgl3/Lwjgl3Launcher.java +++ b/lwjgl3/src/main/java/me/stringfromjava/funkin/lwjgl3/Lwjgl3Launcher.java @@ -3,9 +3,10 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowAdapter; -import me.stringfromjava.funkin.Funkin; +import me.stringfromjava.flixelgdx.Flixel; import me.stringfromjava.funkin.FunkinGame; -import me.stringfromjava.funkin.util.Constants; +import me.stringfromjava.funkin.init.InitScreen; +import me.stringfromjava.funkin.util.FunkinConstants; /** Launches the desktop (LWJGL3) application. */ public class Lwjgl3Launcher { @@ -18,26 +19,29 @@ public static void main(String[] args) { } private static void createApplication() { - FunkinGame game = new FunkinGame(); - Funkin.initialize(game); // This is VERY important to do before creating the application! + FunkinGame game = new FunkinGame( + FunkinConstants.WINDOW_TITLE, + FunkinConstants.WINDOW_WIDTH, + FunkinConstants.WINDOW_HEIGHT, + new InitScreen() + ); + Flixel.initialize(game); // This is VERY important to do before creating the application! new Lwjgl3Application(game, createWindowConfiguration()); } private static Lwjgl3ApplicationConfiguration createWindowConfiguration() { Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration(); - configuration.setTitle("Friday Night Funkin': Java Edition"); + configuration.setTitle("Friday Night Flixel': Java Edition"); // Vsync limits the frames per second to what your hardware can display, and helps eliminate // screen tearing. This setting doesn't always work on Linux, so the line after is a safeguard. configuration.useVsync(true); // Limits FPS to the refresh rate of the currently active monitor, plus 1 to try to match - // fractional - // refresh rates. The Vsync setting above should limit the actual FPS to match the monitor. + // fractional refresh rates. The Vsync setting above should limit the actual FPS to match the monitor. configuration.setForegroundFPS(Lwjgl3ApplicationConfiguration.getDisplayMode().refreshRate + 1); // If you remove the above line and set Vsync to false, you can get unlimited FPS, which can be // useful for testing performance, but can also be very stressful to some hardware. - // You may also need to configure GPU drivers to fully disable Vsync; this can cause screen - // tearing. - configuration.setWindowedMode(Constants.Display.WINDOW_WIDTH, Constants.Display.WINDOW_HEIGHT); + // You may also need to configure GPU drivers to fully disable Vsync; this can cause screen tearing. + configuration.setWindowedMode(FunkinConstants.WINDOW_WIDTH, FunkinConstants.WINDOW_HEIGHT); // You can change these files; they are in lwjgl3/src/main/resources/ . // They can also be loaded from the root of assets/ . configuration.setWindowIcon("icon128.png", "icon64.png", "icon32.png", "icon16.png"); @@ -49,19 +53,19 @@ private static Lwjgl3ApplicationConfiguration createWindowConfiguration() { @Override public void focusGained() { super.focusGained(); - Funkin.getGame().onWindowFocused(); + Flixel.getGame().onWindowFocused(); } @Override public void focusLost() { super.focusLost(); - Funkin.getGame().onWindowUnfocused(); + Flixel.getGame().onWindowUnfocused(); } @Override public void iconified(boolean isIconified) { super.iconified(isIconified); - Funkin.getGame().onWindowMinimized(isIconified); + Flixel.getGame().onWindowMinimized(isIconified); } });