-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐣 Start with the
korge-hello-world
template
- Loading branch information
0 parents
commit e2f9847
Showing
12 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.gradle | ||
/.idea | ||
/build | ||
*.iml | ||
*.hprof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Carlos Ballesteros Velasco | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# 🎮 HitKlack on Korge | ||
|
||
Let's port my [HitKlack](https://github.com/TobseF/HitKlack) game from [LibGDX](https://libgdx.badlogicgames.com/) to [Korge](https://korge.soywiz.com/) engine. | ||
|
||
Setup is bases on the [korge-hello-world template](https://github.com/korlibs/korge-hello-world). | ||
|
||
|
||
For Windows, change all the `./gradlew` for `gradlew.bat`. | ||
|
||
## Compiling for the JVM (Desktop) | ||
|
||
Inside IntelliJ you can go to the `src/commonMain/kotlin/main.kt` file and press the green ▶️ icon | ||
that appears to the left of the `suspend fun main()` line. | ||
|
||
Using gradle tasks on the terminal: | ||
|
||
```bash | ||
./gradlew runJvm # Runs the program | ||
./gradlew packageJvmFatJar # Creates a FAT Jar with the program | ||
./gradlew packageJvmFatJarProguard # Creates a FAT Jar with the program and applies Proguard to reduce the size | ||
``` | ||
|
||
Fat JARs are stored in the `/build/libs` folder. | ||
|
||
## Compiling for the Web | ||
|
||
Using gradle tasks on the terminal: | ||
|
||
```bash | ||
./gradlew jsWeb # Outputs to /build/web | ||
./gradlew jsWebMin # Outputs to /build/web-min (applying Dead Code Elimination) | ||
./gradlew jsWebMinWebpack # Outputs to /build/web-min-webpack (minimizing and grouping into a single bundle.js file) | ||
./gradlew runJs # Outputs to /build/web, creates a small http server and opens a browser | ||
``` | ||
|
||
You can use any HTTP server to serve the files in your browser. | ||
For example using: `npm -g install http-server` and then executing `hs build/web`. | ||
|
||
You can also use `./gradlew -t jsWeb` to continuously building the JS sources and running `hs build/web` in another terminal. | ||
Here you can find a `testJs.sh` script doing exactly this for convenience. | ||
|
||
You can run your tests using Node.JS by calling `jsTest` or in a headless chrome with `jsTestChrome`. | ||
|
||
## Compiling for Native Desktop (Windows, Linux and macOS) | ||
|
||
Using gradle tasks on the terminal: | ||
|
||
```bash | ||
./gradlew linkMainDebugExecutableMacosX64 # Outputs to /build/bin/macosX64/mainDebugExecutable/main.kexe | ||
./gradlew linkMainDebugExecutableLinuxX64 # Outputs to /build/bin/linuxX64/mainDebugExecutable/main.kexe | ||
./gradlew linkMainDebugExecutableMingwX64 # Outputs to /build/bin/mingwX64/mainDebugExecutable/main.exe | ||
``` | ||
|
||
Note that windows executables doesn't have icons bundled. | ||
You can use [ResourceHacker](http://www.angusj.com/resourcehacker/) to add an icon to the executable for the moment. | ||
Later this will be done automatically. | ||
|
||
### Cross-Compiling for Linux/Windows | ||
|
||
If you have docker installed, you can generate native executables for linux and windows | ||
using the cross-compiling gradle wrappers: | ||
|
||
```bash | ||
./gradlew_linux linkMainDebugExecutableLinuxX64 # Outputs to /build/web | ||
./gradlew_win linkMainDebugExecutableMingwX64 # Outputs to /build/web | ||
``` | ||
|
||
### Generating MacOS `.app` | ||
|
||
```bash | ||
./gradlew packageMacosX64AppDebug # Outputs to /build/unnamed-debug.app | ||
``` | ||
|
||
You can change `Debug` for `Release` in all the tasks to generate Release executables. | ||
|
||
You can use the `strip` tool from your toolchain (or in the case of windows found in the ``~/.konan` toolchain) | ||
to further reduce Debug and Release executables size by removing debug information (in some cases this will shrink the EXE size by 50%). | ||
|
||
In windows this exe is at: `%USERPROFILE%\.konan\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1\bin\strip.exe`. | ||
|
||
### Linux notes | ||
|
||
Since linux doesn't provide standard multimedia libraries out of the box, | ||
you will need to have installed the following packages: `freeglut3-dev` and `libopenal-dev`. | ||
|
||
In ubuntu you can use `apt-get`: `sudo apt-get -y install freeglut3-dev libopenal-dev`. | ||
|
||
## Compiling for Android | ||
|
||
You will need to have installed the Android SDK in the default path for your operating system | ||
or to provide the `ANDROID_SDK` environment variable. The easiest way is to install Android Studio. | ||
|
||
Using gradle tasks on the terminal: | ||
|
||
### Native Android (JVM) | ||
|
||
```bash | ||
./gradlew installAndroidDebug # Installs an APK in all the connected devices | ||
./gradlew runAndroidEmulatorDebug # Runs the application in an emulator | ||
``` | ||
|
||
Triggering these tasks, it generates a separate android project into `build/platforms/android`. | ||
You can open it in `Android Studio` for debugging and additional tasks. The KorGE plugin just | ||
delegates gradle tasks to that gradle project. | ||
|
||
### Apache Cordova (JS) | ||
|
||
```bash | ||
./gradlew compileCordovaAndroid # Just compiles cordova from Android | ||
./gradlew runCordovaAndroid # Runs the application (dce'd, minimized and webpacked) in an Android device | ||
./gradlew runCordovaAndroidNoMinimized # Runs the application in Android without minimizing (so you can use `chrome://inspect` to debug the application easier) | ||
``` | ||
|
||
|
||
|
||
## Compiling for iOS | ||
|
||
You will need XCode and to download the iOS SDKs using Xcode. | ||
|
||
Using gradle tasks on the terminal: | ||
|
||
### Native iOS (Kotlin/Native) + Objective-C | ||
|
||
Note that the necessary bridges are built using Objective-C instead of Swift, so the application | ||
won't include Swift's runtime. | ||
|
||
```bash | ||
./gradlew iosBuildSimulatorDebug # Creates an APP file | ||
./gradlew iosInstallSimulatorDebug # Installs an APP file in the simulator | ||
./gradlew iosRunSimulatorDebug # Runs the APP in the simulator | ||
|
||
``` | ||
|
||
These tasks generate a xcode project in `build/platforms/ios`, so you can also open the project | ||
with XCode and do additional tasks there. | ||
|
||
It uses [XCodeGen](https://github.com/yonaskolb/XcodeGen) for the project generation | ||
and [ios-deploy](https://github.com/ios-control/ios-deploy) for deploying to real devices. | ||
|
||
### Apache Cordova (JS) | ||
|
||
```bash | ||
./gradlew compileCordovaIos # Just compiles cordova from iOS | ||
./gradlew runCordovaIos # Runs the application (dce'd, minimized and webpacked) in an iOS device | ||
./gradlew runCordovaIosNoMinimized # Runs the application in iOS without minimizing (so you can use Safari on macOS to debug the application easier) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.soywiz.korge.gradle.* | ||
|
||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
maven { url = uri("https://dl.bintray.com/soywiz/soywiz") } | ||
maven { url = uri("https://plugins.gradle.org/m2/") } | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath("com.soywiz:korge-gradle-plugin:1.1.1") | ||
} | ||
} | ||
|
||
apply(plugin = "korge") | ||
|
||
korge { | ||
id = "com.sample.demo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.jvmargs=-Xmx1536m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#!/usr/bin/env sh | ||
|
||
############################################################################## | ||
## | ||
## Gradle start up script for UN*X | ||
## | ||
############################################################################## | ||
|
||
# Attempt to set APP_HOME | ||
# Resolve links: $0 may be a link | ||
PRG="$0" | ||
# Need this for relative symlinks. | ||
while [ -h "$PRG" ] ; do | ||
ls=`ls -ld "$PRG"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
PRG=`dirname "$PRG"`"/$link" | ||
fi | ||
done | ||
SAVED="`pwd`" | ||
cd "`dirname \"$PRG\"`/" >/dev/null | ||
APP_HOME="`pwd -P`" | ||
cd "$SAVED" >/dev/null | ||
|
||
APP_NAME="Gradle" | ||
APP_BASE_NAME=`basename "$0"` | ||
|
||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
DEFAULT_JVM_OPTS='"-Xmx64m"' | ||
|
||
# Use the maximum available, or set MAX_FD != -1 to use that value. | ||
MAX_FD="maximum" | ||
|
||
warn () { | ||
echo "$*" | ||
} | ||
|
||
die () { | ||
echo | ||
echo "$*" | ||
echo | ||
exit 1 | ||
} | ||
|
||
# OS specific support (must be 'true' or 'false'). | ||
cygwin=false | ||
msys=false | ||
darwin=false | ||
nonstop=false | ||
case "`uname`" in | ||
CYGWIN* ) | ||
cygwin=true | ||
;; | ||
Darwin* ) | ||
darwin=true | ||
;; | ||
MINGW* ) | ||
msys=true | ||
;; | ||
NONSTOP* ) | ||
nonstop=true | ||
;; | ||
esac | ||
|
||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
|
||
# Determine the Java command to use to start the JVM. | ||
if [ -n "$JAVA_HOME" ] ; then | ||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
# IBM's JDK on AIX uses strange locations for the executables | ||
JAVACMD="$JAVA_HOME/jre/sh/java" | ||
else | ||
JAVACMD="$JAVA_HOME/bin/java" | ||
fi | ||
if [ ! -x "$JAVACMD" ] ; then | ||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
Please set the JAVA_HOME variable in your environment to match the | ||
location of your Java installation." | ||
fi | ||
else | ||
JAVACMD="java" | ||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
Please set the JAVA_HOME variable in your environment to match the | ||
location of your Java installation." | ||
fi | ||
|
||
# Increase the maximum file descriptors if we can. | ||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | ||
MAX_FD_LIMIT=`ulimit -H -n` | ||
if [ $? -eq 0 ] ; then | ||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
MAX_FD="$MAX_FD_LIMIT" | ||
fi | ||
ulimit -n $MAX_FD | ||
if [ $? -ne 0 ] ; then | ||
warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
fi | ||
else | ||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
fi | ||
fi | ||
|
||
# For Darwin, add options to specify how the application appears in the dock | ||
if $darwin; then | ||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
fi | ||
|
||
# For Cygwin, switch paths to Windows format before running java | ||
if $cygwin ; then | ||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
JAVACMD=`cygpath --unix "$JAVACMD"` | ||
|
||
# We build the pattern for arguments to be converted via cygpath | ||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
SEP="" | ||
for dir in $ROOTDIRSRAW ; do | ||
ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
SEP="|" | ||
done | ||
OURCYGPATTERN="(^($ROOTDIRS))" | ||
# Add a user-defined pattern to the cygpath arguments | ||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
fi | ||
# Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
i=0 | ||
for arg in "$@" ; do | ||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
|
||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
else | ||
eval `echo args$i`="\"$arg\"" | ||
fi | ||
i=$((i+1)) | ||
done | ||
case $i in | ||
(0) set -- ;; | ||
(1) set -- "$args0" ;; | ||
(2) set -- "$args0" "$args1" ;; | ||
(3) set -- "$args0" "$args1" "$args2" ;; | ||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
esac | ||
fi | ||
|
||
# Escape application args | ||
save () { | ||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | ||
echo " " | ||
} | ||
APP_ARGS=$(save "$@") | ||
|
||
# Collect all arguments for the java command, following the shell quoting and substitution rules | ||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | ||
|
||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong | ||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then | ||
cd "$(dirname "$0")" | ||
fi | ||
|
||
exec "$JAVACMD" "$@" |
Oops, something went wrong.