|
| 1 | +# Cross-platform-template |
| 2 | +[](https://www.codacy.com/gh/Monkey-Droid/CrossPlatformModule/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Monkey-Droid/CrossPlatformModule&utm_campaign=Badge_Grade) |
| 3 | + |
| 4 | +A cross platform template for jMonkeyEngine games supporting both common-platform and platform-specific environment using gradle sub-projects. |
| 5 | + |
| 6 | +# Modules: |
| 7 | +1) Game module `:game` : holds `build.gradle` dependencies for the game code & should hold your code. |
| 8 | +2) Game-assets module `:game-assets`: holds game assets at `./game-assets/src/main/resources` and supports java code specific to loading assets which is also a cross-platform module. |
| 9 | +3) Desktop module `:desktop` : holds `build.gradle` for desktop dependencies and implements the `:game` module and the `game-assets` module, this module can hold the desktop dependent gui and hardware code. |
| 10 | +4) Android module `:android` : holds `build.gradle` for the android dependencies and implements the `:game` module and the `game-assets` module, this module can hold android dependent gui and hardware code. |
| 11 | + |
| 12 | +# Features: |
| 13 | +- [x] A platform independent assets module `:game-assets` for game assets. |
| 14 | +- [x] A platform independent game module `:game` for game logic. |
| 15 | +- [x] Android Support via `:android` module. |
| 16 | +- [x] Desktop Support via `:desktop` module. |
| 17 | +- [x] Desktop executable jar building task. |
| 18 | +- [x] Automate game building using gradle tasks via GitHub CI. |
| 19 | +- [ ] Automate game releasing `on-release` via GitHub CI `on-release` action. |
| 20 | +- [ ] Android emulator and adb helper tasks (wip). |
| 21 | + |
| 22 | +# Running Game: |
| 23 | + |
| 24 | +### On Desktop: |
| 25 | + |
| 26 | +```gradle |
| 27 | +./gradlew run |
| 28 | +``` |
| 29 | + |
| 30 | +### On Android: |
| 31 | + |
| 32 | +Install the app on a connected device via adb. |
| 33 | + |
| 34 | +```bash |
| 35 | +┌─[✗]─[twisted@parrot]─[~/AndroidStudioProjects/CrossPlatformModule] |
| 36 | +└──╼ $./gradlew :android:installDebug |
| 37 | + |
| 38 | +> Task :app:installDebug |
| 39 | +Installing APK 'app-debug.apk' on 'Redmi Note 6 Pro - 10' for app:debug |
| 40 | +Installed on 1 device. |
| 41 | + |
| 42 | +BUILD SUCCESSFUL in 4s |
| 43 | +33 actionable tasks: 1 executed, 32 up-to-date |
| 44 | +``` |
| 45 | + |
| 46 | +# Building Game: |
| 47 | + |
| 48 | +### Desktop: |
| 49 | +```bash |
| 50 | +$./gradlew :desktop:clean && |
| 51 | + ./gradlew :desktop:build && |
| 52 | + ./gradlew :desktop:copyJars && |
| 53 | + ./gradlew :desktop:releaseJar |
| 54 | +``` |
| 55 | + |
| 56 | + |
| 57 | +### Android: |
| 58 | +```gradle |
| 59 | +$./gradlew :android:clean && |
| 60 | + ./gradlew :android:build && |
| 61 | + ./gradlew :android:assemble |
| 62 | +``` |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +## Appendix: |
| 68 | + |
| 69 | +### Credits: |
| 70 | +=> Thanks [Ali_RS](https://hub.jmonkeyengine.org/u/ali_rs/summary) for the suggestion of separating game and game-assets module from desktop and android ones. <br/> |
| 71 | +=> Thanks [wizzardo](https://hub.jmonkeyengine.org/u/wizzardo/summary) for fixing creating jar from desktop issue. <br/> |
| 72 | + |
| 73 | +### References: |
| 74 | + |
| 75 | +=> [Android studio-AGP-Gradle release notes](https://developer.android.com/studio/releases/gradle-plugin) |
| 76 | + |
| 77 | +=> [Gradle wrapper for android](https://developer.android.com/studio/build/building-cmdline) |
| 78 | + |
| 79 | +=> [Gradle DSL](https://docs.gradle.org/current/dsl/index.html) |
| 80 | + |
| 81 | +=> [Gradle multi-project-builds](https://docs.gradle.org/current/userguide/multi_project_builds.html) |
| 82 | + |
| 83 | +=> [Gradle/Groovy Udacity course by google](https://github.com/udacity/ud867/blob/master/1.11-Exercise-ConfigureFileSystemTasks/solution.gradle) |
| 84 | + |
| 85 | +=> See JMonkeyEngine Android Examples: |
| 86 | +- [jme3-simple-examples](https://github.com/Scrappers-glitch/jme3-Simple-Examples) |
| 87 | +- [DB-Training-App](https://github.com/Scrappers-glitch/DBTraining) |
| 88 | +- [SEE-Demo](https://github.com/Scrappers-glitch/Superior-Extended-Engine/tree/master/demoApp) |
| 89 | + |
| 90 | +=> See JMonkeyEngine RPI armhf Desktop Example: |
| 91 | +- [JmeCarPhysicsTestRPI](https://github.com/Scrappers-glitch/JmeCarPhysicsTestRPI) |
| 92 | +- [GPIOJmeCarTest](https://github.com/Software-Hardware-Codesign/JmeCarPhysicsTestRPI/blob/master/src/main/java/GPIOJmeCarTest.java) |
0 commit comments