han-yaeger / yaeger-tutorial

Yaeger Tutorial: Creating Waterworld
2 stars 51 forks source link

Update to 2022-2023 #11

Closed Jaapapa closed 10 months ago

Jaapapa commented 1 year ago

Currently the Tutorial uses version 2021.2022.3, but version 2022.2023 was released a while ago, with some new features including support for easier sprite animation. Also, a breaking change is introduced in the API for Collidable, namely the way onCollision() works. The tutorial should be updated to use the new version without compilation errors.

ajdejong3 commented 1 year ago

When you change the version in pom.xml from 2021.2022.3 to 2022.2023 there are errors about the onCollision method in Bubble.java and Hanny.java. After changing: public void onCollision(Collider collidingObject) to public void onCollision(List collidingObject) the game can be run but it gives a white screen and the following error messages:

/usr/lib64/jvm/java-17-openjdk-17/bin/java -javaagent:/home/arjan/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8109.175/lib/idea_rt.jar=37839:/home/arjan/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8109.175/bin -Dfile.encoding=UTF-8 -classpath /home/arjan/.m2/repository/org/openjfx/javafx-base/19/javafx-base-19.jar:/home/arjan/.m2/repository/org/openjfx/javafx-controls/19/javafx-controls-19.jar:/home/arjan/.m2/repository/org/openjfx/javafx-graphics/19/javafx-graphics-19.jar:/home/arjan/.m2/repository/org/openjfx/javafx-media/19/javafx-media-19.jar:/home/arjan/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/arjan/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/arjan/.m2/repository/com/google/guava/guava/30.1-jre/guava-30.1-jre.jar:/home/arjan/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/home/arjan/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/home/arjan/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/home/arjan/.m2/repository/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar:/home/arjan/.m2/repository/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar:/home/arjan/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar -p /home/arjan/.m2/repository/com/google/inject/guice/5.1.0/guice-5.1.0.jar:/home/arjan/.m2/repository/org/openjfx/javafx-base/19/javafx-base-19-linux.jar:/home/arjan/.m2/repository/org/openjfx/javafx-graphics/19/javafx-graphics-19-linux.jar:/home/arjan/.m2/repository/org/openjfx/javafx-media/19/javafx-media-19-linux.jar:/data/han/git/extern/jaar1/seb/ogp/yaeger-tutorial/target/classes:/home/arjan/.m2/repository/org/openjfx/javafx-controls/19/javafx-controls-19-linux.jar:/home/arjan/.m2/repository/com/github/han-yaeger/yaeger/2022.2023/yaeger-2022.2023.jar -m waterworld/com.github.hanyaeger.tutorial.Waterworld Exception in thread "JavaFX Application Thread" com.github.hanyaeger.core.exceptions.YaegerEngineException: java.lang.reflect.InvocationTargetException at hanyaeger@2022.2023/com.github.hanyaeger.core.annotations.AnnotationProcessor.invoke(AnnotationProcessor.java:46) at hanyaeger@2022.2023/com.github.hanyaeger.core.annotations.AnnotationProcessor.invokeActivators(AnnotationProcessor.java:28) at hanyaeger@2022.2023/com.github.hanyaeger.core.SceneCollection.activate(SceneCollection.java:96) at hanyaeger@2022.2023/com.github.hanyaeger.core.SceneCollection.setActive(SceneCollection.java:89) at hanyaeger@2022.2023/com.github.hanyaeger.core.YaegerStage.setActiveScene(YaegerStage.java:108) at hanyaeger@2022.2023/com.github.hanyaeger.api.YaegerGame.setActiveScene(YaegerGame.java:43) at waterworld/com.github.hanyaeger.tutorial.entities.buttons.StartButton.onMouseButtonPressed(StartButton.java:28) at hanyaeger@2022.2023/com.github.hanyaeger.api.userinput.MouseButtonPressedListener.handleEvent(MouseButtonPressedListener.java:42) at javafx.base@19/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234) at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at javafx.base@19/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at javafx.base@19/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at javafx.base@19/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.base@19/javafx.event.Event.fireEvent(Event.java:198) at javafx.graphics@19/javafx.scene.Scene$MouseHandler.process(Scene.java:3894) at javafx.graphics@19/javafx.scene.Scene.processMouseEvent(Scene.java:1887) at javafx.graphics@19/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2620) at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411) at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450) at javafx.graphics@19/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424) at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449) at javafx.graphics@19/com.sun.glass.ui.View.handleMouseEvent(View.java:551) at javafx.graphics@19/com.sun.glass.ui.View.notifyMouse(View.java:937) at javafx.graphics@19/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at javafx.graphics@19/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at hanyaeger@2022.2023/com.github.hanyaeger.core.annotations.AnnotationProcessor.invoke(AnnotationProcessor.java:44) ... 34 more Caused by: com.github.hanyaeger.core.exceptions.FailedToInstantiateEntityException: Unable to instantiate an Entity for the TileMap at hanyaeger@2022.2023/com.github.hanyaeger.core.factories.TileFactory.create(TileFactory.java:54) at hanyaeger@2022.2023/com.github.hanyaeger.api.scenes.TileMap.transformMapToEntities(TileMap.java:249) at hanyaeger@2022.2023/com.github.hanyaeger.api.scenes.TileMap.activate(TileMap.java:145) at hanyaeger@2022.2023/com.github.hanyaeger.api.scenes.TileMapContainer.lambda$configureTileMaps$2(TileMapContainer.java:57) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at hanyaeger@2022.2023/com.github.hanyaeger.api.scenes.TileMapContainer.configureTileMaps(TileMapContainer.java:55) at hanyaeger@2022.2023/com.github.hanyaeger.api.scenes.TileMapContainer.initTileMaps(TileMapContainer.java:30) ... 39 more Caused by: java.lang.IllegalAccessException: class com.github.hanyaeger.core.factories.TileFactory (in module hanyaeger) cannot access class com.github.hanyaeger.tutorial.entities.map.Coral (in module waterworld) because module waterworld does not export com.github.hanyaeger.tutorial.entities.map to module hanyaeger at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:489) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at hanyaeger@2022.2023/com.github.hanyaeger.core.factories.TileFactory.create(TileFactory.java:49) ... 45 more

I ran the game on linux using openjdk 17.0.6.

ajdejong3 commented 1 year ago

When doing the same on Windows I can play the game. The collisions with the shark works as expected, but when the player collides with an instance of bubble the game crashes to a white screen and gives the following error:

"C:\Program Files\Java\jdk-17\bin\java.exe" -javaagent:C:\Users\Arjan\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\231.8109.175\lib\idea_rt.jar=61984:C:\Users\Arjan\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\231.8109.175\bin -Dfile.encoding=UTF-8 -classpath C:\Users\Arjan.m2\repository\org\openjfx\javafx-base\19\javafx-base-19.jar;C:\Users\Arjan.m2\repository\org\openjfx\javafx-controls\19\javafx-controls-19.jar;C:\Users\Arjan.m2\repository\org\openjfx\javafx-graphics\19\javafx-graphics-19.jar;C:\Users\Arjan.m2\repository\org\openjfx\javafx-media\19\javafx-media-19.jar;C:\Users\Arjan.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\Arjan.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\Arjan.m2\repository\com\google\guava\guava\30.1-jre\guava-30.1-jre.jar;C:\Users\Arjan.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\Arjan.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\Arjan.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\Arjan.m2\repository\org\checkerframework\checker-qual\3.5.0\checker-qual-3.5.0.jar;C:\Users\Arjan.m2\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;C:\Users\Arjan.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar -p C:\Users\Arjan.m2\repository\org\openjfx\javafx-controls\19\javafx-controls-19-win.jar;C:\Users\Arjan.m2\repository\org\openjfx\javafx-media\19\javafx-media-19-win.jar;C:\Users\Arjan.m2\repository\org\openjfx\javafx-graphics\19\javafx-graphics-19-win.jar;D:\Han\git\extern\jaar1\seb\yaeger-tutorial\target\classes;C:\Users\Arjan.m2\repository\org\openjfx\javafx-base\19\javafx-base-19-win.jar;C:\Users\Arjan.m2\repository\com\github\han-yaeger\yaeger\2022.2023\yaeger-2022.2023.jar;C:\Users\Arjan.m2\repository\com\google\inject\guice\5.1.0\guice-5.1.0.jar -m waterworld/com.github.hanyaeger.tutorial.Waterworld Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "com.github.hanyaeger.api.userinput.KeyListener.onPressedKeysChange(java.util.Set)" because "this.keyListener" is null at hanyaeger@2022.2023/com.github.hanyaeger.core.scenes.delegates.KeyListenerDelegate.inputChanged(KeyListenerDelegate.java:79) at hanyaeger@2022.2023/com.github.hanyaeger.core.scenes.delegates.KeyListenerDelegate.triggerManualEvent(KeyListenerDelegate.java:58) at hanyaeger@2022.2023/com.github.hanyaeger.core.factories.animationtimer.AnimationTimerFactory$1.handleOn60fps(AnimationTimerFactory.java:26) at hanyaeger@2022.2023/com.github.hanyaeger.core.YaegerAnimationTimer.handle(YaegerAnimationTimer.java:41) at javafx.graphics@19/javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$0(AnimationTimer.java:58) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at javafx.graphics@19/javafx.animation.AnimationTimer$AnimationTimerReceiver.handle(AnimationTimer.java:57) at javafx.graphics@19/com.sun.scenario.animation.AbstractPrimaryTimer.timePulseImpl(AbstractPrimaryTimer.java:356) at javafx.graphics@19/com.sun.scenario.animation.AbstractPrimaryTimer$MainLoop.run(AbstractPrimaryTimer.java:266) at javafx.graphics@19/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:571) at javafx.graphics@19/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555) at javafx.graphics@19/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548) at javafx.graphics@19/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:352) at javafx.graphics@19/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics@19/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@19/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) at java.base/java.lang.Thread.run(Thread.java:833)

Jaapapa commented 1 year ago

You are correct, the latest version is different from the version currently used in the tutorial. You ran into one of the breaking changes. Currently, the tutorial is not yet written for 2022-2023. This issue is logged to change the tutorial to the new version. I would advise you to use the version mentioned and used in the tutorial itself to save yourself the headache of this version update while learning the engine.

A little more info on the breaking change: In the new version the onCollision() method uses a List parameter with Colliders instead of a single Collider. In this way you can easier create code for the cases where a Collided touches multiple Colliders at the same time. If you want, you can use a ForEach loop to recreate the behaviour similar to the 'old' version:

    @Override
    public void onCollision(List<Collider> collidingObjects) {
        for (Collider collidingObject : collidingObjects) {
            if (collidingObject instanceof Coral) {
                setSpeed(0);
            } else if (collidingObject instanceof AirBubble) {
etc...
meronbrouwer commented 10 months ago

The tutorial has been updated to version 2023.2024.