AlmasB / FXGLGames

This repo contains sample games built with FXGL
http://almasb.github.io/FXGLGames/
MIT License
807 stars 325 forks source link

KeyRain - test with JEP330 launch #13

Open apws opened 3 years ago

apws commented 3 years ago

Hello Almas, I am just playing with some JavaFX examples using JEP330 launching, as I found for my first experiments, that basically launch(YourAppClass.class, args) works with on-the-fly classloading.

I quickly fetched required modules from maven (ya, manually, very quickly, so game works....) and found that it tries to access EntityType.main(String[]) so I put him here passing of launch and it kinda works, but crashes on mouse input ...

Can you pls quickly think what can be failing and why the Enum main is required for something??

In run.txt there is command to execute the KeyRainApp.jxc file (containing java sources of your app) There are even 2 log files where it crashed (but I had to put app.main into enum.main !!! why??)

Its just a experiment to allow quick and dirty changes to tiny apps, now also using some referenced/provided modules...

(I am sharing this my BEGINNERS samples approach with gluon too, found it very cool for tiny things - your example was challenging as it required MANY modules and I manually fed here one by one all of them - some kind of dependecy scan and load from maven will be coo )))

But sure - I also CAN use maven finally - its easy and your tiny example is at the edge of usability of JEP330 - that was the goal to try here :-)))

(sorry, gmail complains about security so I replaced modules only by list of them)

UPDATE: Well, it in fact works :))) but the Enum.main is something I couldnt understand, really

Thanks, Petr 210327-FXGL-Keyrain-JEP330.zip

apws commented 3 years ago

tried to push to the limits JEP-330, I also modified Breakout with such changes - it in fact works, it looks that enum with main(args) is some weird thing, I dont know where, but there was second weirdness, as enum class needs to be referenced explicitly as EnumName.ITEM everywhere, otherwise on-the-fly JEP330 compilation complains

-- required changes marked by //MIXWORX comment:

a) everything in single package, everything in single file, "assets" in current folder

b) AGAIN enum class main(args) required to launch !!! (the same issue as in FXGLGame KeyRain) c) + enum references needs to be specific EnumType.ITEM !!!

(probably different behavior of internal compilar against javac ??!!??!!??)

d) + SINGLE name clash in single-file imports into default package - resolved this way? import com.almasb.fxgl.dsl.components.Effect; //MIXWORX clash - used in BallComponent //import javafx.scene.effect.Effect; //MIXWORX clash - used as full name in BatComponent

Breakout.zip

apws commented 3 years ago

mea culpa, issues with enums are caused by "import static" and inside Breakout, such imports was commented out ... still is interesting how it relates to main() - probably because of "static" import, but its weird; according to JEP-330, first public class with static main() is expected as launcher; I tried to place enum anywhere, public or private ... just weird ))