Wednesday, March 11, 2020

Cross platform gaming - SpaceFX

Aloha,

It was planned to show the latest version of SpaceFX at JavaLand conf but unfortunately this was cancelled due to COVID-19. Well lucky us we are all connected via the internet so I decided to give you the information here on my blog...

Once I've started coding the SpaceFX game I had several things on my mind...first was would it run on the browser user jpro? Yes it does...not super fast but hey...it's JavaFX running in the browser...without a plugin :)

Then I thought why not giving it a try on mobile like iOS and Android using Gluon. Well to be honest I was more than surprised how well that worked out.
The game runs smoothly on my iPhone and Android phone...well at the moment without sound but that's just a question of time.

Now I finally have it running on...

  • OS X
  • Linux
  • Windows
  • iOS
  • Android
  • Web
...from one source!!!



Because there is no support for sound on mobile at the moment I've created a mobile branch where I simply commented out all lines related to sound. The property file management is also a bit different on mobile but the rest is the same.

Oh and before someone blame me again that it does not work on Linux blablabla...
It works on my Ubuntu 18.04 LTS machine totally fine...with sound (at least the executable jar) and yes it also works on my Windows 10 Virtual Machine. I hope I do not always have to provide screenshots to proof this, you just have to believe me :)

So I've created executable jars, native packages using JDK14 jpackage and native images using GraalVM+Substrate and because many asked for the compiled versions you can now download them here:

OS X:

iOS:
  • iOS app (please unzip before install)

Linux:
  • Executable jar (run on JDK11 with java -jar SpaceFX-1.0-SNAPSHOT.jar)
  • Binary (GraalVM/Substrate version without sound)

Android:

Windows:

Attention:
Please keep in mind that I only tested the iOS and Android versions on phones (iPhone 11 Pro and Huawei P20 light). It might not work on tablets like iPads etc.

But if you are interested in the code or would like to compile/run it yourself, you can find the code as always on github.

And now another video...just for the fun of it...



That's it for today...so keep coding... :)

5 comments:

  1. Very good job, thanks.

    Windows Executable jar is - verified on Windows 10 machine.

    Android apk version is ok on Huawei P20 Lite - verified on smartphone of my daughter.
    But on my smartphone Motorola Moto G5S Plus is instalation of apk failed (Android 8.1.0), chunk of log:
    -------------------------------------------------
    Historical Broadcast foreground #13:
    BroadcastRecord{f91d41c u0 com.android.packageinstaller.ACTION_INSTALL_COMMIT} to user 0
    Intent { act=com.android.packageinstaller.ACTION_INSTALL_COMMIT flg=0x10000010 pkg=com.google.android.packageinstaller (has extras) }
    extras: Bundle[{android.content.pm.extra.STATUS=7, EventResultPersister.EXTRA_ID=-2147483644, android.content.pm.extra.PACKAGE_NAME=eu.hansolo.spacefx.spacefx, android.content.pm.extra.SESSION_ID=82725561, android.content.pm.extra.LEGACY_STATUS=-113, android.content.pm.extra.STATUS_MESSAGE=INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113}]
    caller=com.google.android.packageinstaller null pid=-1 uid=10042
    -------------------------------------------------

    Important is this (in my opinion): android.content.pm.extra.STATUS_MESSAGE=INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries

    Don't is better native development for Android?
    More range of supported Android devices.

    ReplyDelete
  2. Just tried the DMG on macOS, works fine. I do wonder why it asks to be able to get key presses even when the application is not active?

    ReplyDelete
  3. It works perfectly on my Linux, OpenSUSE Leap 15.1

    Though I had one problem. I think because of the following bug.
    https://github.com/javafxports/openjdk-jfx/issues/222
    This should be fixed I think in JavaFX 14. A workaround was to make the window resizeable, then rebuild and it worked fine.

    ReplyDelete
  4. Why there is no sound support on mobile?

    ReplyDelete
    Replies
    1. Because the Gluon guys are too busy and did not found the time yet to implement it for mobile. So technically there is no reason not to have sound and it will come. But for standard apps sound is not that important at the moment.

      Delete