Game crashes at about 50 points #1

Closed
opened 2024-01-29 12:20:04 +00:00 by manolol1 · 1 comment
manolol1 commented 2024-01-29 12:20:04 +00:00 (Migrated from github.com)

Exception in thread "main" java.lang.IllegalStateException: Array is empty.
at com.badlogic.gdx.utils.Array.peek(Array.java:364)
at xyz.manolol.endlessrunner.screens.GameScreen.render(GameScreen.java:123)
at com.badlogic.gdx.Game.render(Game.java:48)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:387)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:193)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.(Lwjgl3Application.java:167)
at xyz.manolol.endlessrunner.DesktopLauncher.main(DesktopLauncher.java:15)

Exception in thread "main" java.lang.IllegalStateException: Array is empty. at com.badlogic.gdx.utils.Array.peek(Array.java:364) at xyz.manolol.endlessrunner.screens.GameScreen.render(GameScreen.java:123) at com.badlogic.gdx.Game.render(Game.java:48) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:387) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:193) at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:167) at xyz.manolol.endlessrunner.DesktopLauncher.main(DesktopLauncher.java:15)
manolol1 commented 2024-01-29 12:22:09 +00:00 (Migrated from github.com)

Might be caused by this:

    // Spawn new Obstacles
    if (obstacles.peek().x < viewport.getWorldWidth() - (obstacleDistance + MathUtils.random(-250.0f, +200.0f))) {
        spawnObstacle(viewport.getWorldWidth());
    }

because the array might be empty at that point. Probably need to implement a check before this.

Might be caused by this: // Spawn new Obstacles if (obstacles.peek().x < viewport.getWorldWidth() - (obstacleDistance + MathUtils.random(-250.0f, +200.0f))) { spawnObstacle(viewport.getWorldWidth()); } because the array might be empty at that point. Probably need to implement a check before this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mario/EndlessRunner#1
No description provided.