Skip to content

Commit 9409309

Browse files
authored
Initial commit
0 parents  commit 9409309

File tree

65 files changed

+2434
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2434
-0
lines changed

.github/workflows/android.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Android CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: set up JDK 11
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: '11'
20+
distribution: 'temurin'
21+
cache: gradle
22+
23+
- name: Permissionize
24+
run: chmod +x ./gradlew
25+
26+
- name: Clean
27+
run: ./gradlew :android:clean
28+
29+
- name: Build
30+
run: ./gradlew :android:build
31+
32+
- name: Assemble
33+
run: ./gradlew :android:assemble
34+

.github/workflows/desktop.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Desktop CI
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the "master" branch
6+
push:
7+
branches: [ "master" ]
8+
pull_request:
9+
branches: [ "master" ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "build"
17+
build:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-latest
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24+
- uses: actions/checkout@v3
25+
26+
- uses: actions/setup-java@v3
27+
with:
28+
distribution: 'oracle'
29+
java-version: '17'
30+
31+
- name: Permissionize
32+
run: chmod +x ./gradlew
33+
34+
- name: Clean
35+
run: ./gradlew :desktop:clean
36+
37+
- name: Build
38+
run: ./gradlew :desktop:build
39+
40+
- name: Assemble
41+
run: ./gradlew :desktop:copyJars && ./gradlew :desktop:releaseJar
42+
43+
- name: Output Binaries
44+
run: ls -aR ./desktop/build/libs

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
*.so

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, Monkey-Droid
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Cross-platform-template
2+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/09d937b3dd2549aea7e304aedc050764)](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+
![](https://github.com/Scrappers-glitch/CrossPlatformModule/blob/master/screenshots/desktop/Screenshot%20at%202021-10-25%2000-08-45.png)
56+
57+
### Android:
58+
```gradle
59+
$./gradlew :android:clean &&
60+
./gradlew :android:build &&
61+
./gradlew :android:assemble
62+
```
63+
![](https://github.com/Scrappers-glitch/CrossPlatformModule/blob/master/screenshots/android/Screenshot_20211025-000113671.jpg)
64+
65+
![](https://github.com/Scrappers-glitch/CrossPlatformModule/blob/master/screenshots/android/Screenshot_20211025-000108283.jpg)
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)

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

android/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
apply from: file("../common.gradle")
6+
7+
android {
8+
compileSdk 33
9+
defaultConfig {
10+
applicationId "com.example.androidmodule"
11+
minSdk 21
12+
targetSdk 33
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
implementation 'androidx.appcompat:appcompat:1.3.1'
33+
implementation 'com.google.android.material:material:1.4.0'
34+
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
35+
testImplementation 'junit:junit:4.13.2'
36+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
37+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
38+
implementation project(path: ':game')
39+
implementation "org.jmonkeyengine:jme3-android-native:3.6.0-beta3"
40+
}

android/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.androidmodule;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.example.androidmodule", appContext.getPackageName());
25+
}
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.androidmodule">
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:extractNativeLibs="true"
13+
android:theme="@style/Theme.AppCompat.NoActionBar"
14+
tools:ignore="AllowBackup">
15+
<activity
16+
android:name=".AndroidLauncher"
17+
android:exported="true"
18+
android:screenOrientation="landscape">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>

0 commit comments

Comments
 (0)