A Hello World and Template for the KorGe game engine

Overview

Korge Hello World and Template

This is a Hello World and Template for the KorGe game engine. Using gradle with kotlin-dsl. You can open this project in IntelliJ IDEA by opening the folder or the build.gradle.kts file.

You can find this template at GitHub: https://github.com/korlibs/korge-hello-world

For Windows, change all the ./gradlew for gradlew.bat.

You should use Gradle 5.5 or greater and Java 8 or greater.

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:

./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:

./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:

./gradlew linkDebugExecutableMacosX64         # Outputs to /build/bin/macosX64/mainDebugExecutable/main.kexe
./gradlew linkDebugExecutableLinuxX64         # Outputs to /build/bin/linuxX64/mainDebugExecutable/main.kexe
./gradlew linkDebugExecutableMingwX64         # Outputs to /build/bin/mingwX64/mainDebugExecutable/main.exe

Note that windows executables doesn't have icons bundled. You can use 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:

./gradlew_linux linkDebugExecutableLinuxX64   # Outputs to /build/web
./gradlew_win   linkDebugExecutableMingwX64   # Outputs to /build/web

Generating MacOS .app

./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)

./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)

./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.

./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 for the project generation and ios-deploy for deploying to real devices.

Apache Cordova (JS)

./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)

JS-game deployment to GitHub Pages

  • Go to settings page and enable GitHub Pages
  • Choose branch github-pages and select folder / (root)
  • After that you can use link:
    link to JS-game, click "View Deployment"
  • When you push to main or master branch, - deployment process will start again with GitHub Actions.
You might also like...
Image Processing Engine with GUI
Image Processing Engine with GUI

Image Processing Engine with GUI Imperial College London Department of Computing Third Year Software Engineer Group Project Supervisor: Dr. Pancham Sh

Candroid Browser is a replacement web browser for Candroid. It is designed to replace the AOSP browser, but not Google Chrome. It will be based on a privacy friendly WebKit engine fork.
Candroid Browser is a replacement web browser for Candroid. It is designed to replace the AOSP browser, but not Google Chrome. It will be based on a privacy friendly WebKit engine fork.

Candroid Browser Candroid Browser is a replacement web browser for Candroid. It is designed to replace the AOSP browser, but not Google Chrome. It wil

My own approach to what I think an Android MVVM project with Clean Architecture should look like with Dagger-Hilt as Dependency Injector engine
My own approach to what I think an Android MVVM project with Clean Architecture should look like with Dagger-Hilt as Dependency Injector engine

MVVM Project Hilt Introducción Este proyecto es mi visión particular, ni mejor ni peor (sólo una más) que cualquier otra aproximación a lo que yo enti

This is a template to help you get started building amazing Kotlin applications and libraries.

Welcome to the Starter This is a template to help you get started building amazing Kotlin applications and libraries. Over time, examples will be comp

Template for building CLI tool in Kotlin and producing native binary

Kotlin command-line native tool template This template allows you to quickly build command-line tool using Kotlin , Clikt and build a native binary fo

Team management service is a production ready and fully tested service that can be used as a template for a microservices development.
Team management service is a production ready and fully tested service that can be used as a template for a microservices development.

team-mgmt-service Description Team management service is a production ready and fully tested service that can be used as a template for a microservice

Kotlin async server template with coroutines and zero deps

kotlin-server At attempt to very light-weight non-blocking http app template with support for Kotlin coroutines. Zero dependencies - Java built-in jdk

XCore is a Open-Source , simple and lightweight API & Template for Android Apps.

XCore XCore is a Open-Source , simple and lightweight API & Template for Android Apps. Support XCore is compatible with Android Studio & Sketchware Pr

Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI
Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI

KMMNewsAPP There are two branches Main News App Main The main branch is a complete template that you can clone and use to build the awesome app that y

Owner
Kiet
Kiet
HelloKMM - Hello World in Kotlin Multiplatform Mobile (new empty project)

Hello KMM! Hello World in Kotlin Multiplatform Mobile (new empty project) Gettin

Blake Barrett 1 Feb 2, 2022
The RuneTopic game server implementation that hosts and processes a game world.

RuneTopic Game Server The RuneTopic game server implementation that hosts and processes a game world. Setup Guide You can host a game server with Dock

Runetopic 2 Jan 13, 2022
WordGuess - A portuguese game inspired in the world fever wordle game

WordGuess WordGuess is a portuguese game inspired in the world fever wordle game

Anthoni Ipiranga 6 Jul 28, 2022
A korge map generator for Pocket Palm Heroes remastered

Korge mapgen This is a korge map generator for Pocket Palm Heroes remastered. Algorithm Is based mostly on this presentation by Gus Smedstad, who is t

Alexey Kononov 4 Sep 6, 2022
An Android application for browsing video games and checking the latest gaming news from around the world.

Gamedge An Android application for browsing video games and checking the latest gaming news from around the world. Built entirely using the Jetpack Co

Paul Rybitskyi 602 Dec 25, 2022
🎓 Learning Kotlin Coroutines for Android by example. 🚀 Sample implementations for real-world Android use cases. 🛠 Unit tests included!

Kotlin Coroutines - Use Cases on Android ?? Learning Kotlin Coroutines for Android by example. ?? Sample implementations for real-world Android use ca

Lukas Lechner 2.1k Jan 3, 2023
CovidTracker traces all the covid-19 cases all over the world.

CovidTracker Crona Tracker trace india covid-19 cases upto district level and can trace other countries cases too. It can also traces user's current l

Anuraj Jain 6 May 22, 2021
CodeLab for the workshop: A Composable New World

A Composable New World! Compose is here! ?? I've created a codelab where you can follow step by step the development of android application using Comp

Carlos Mota 9 Nov 25, 2022
Kotlin-phoenix - A set of tools aimed to bridge Phoenix with the Kotlin Multiplatform world

Kotlin Phoenix This project is aimed to allow developers to work with Phoenix Ch

Adrien Jacquier Bret 5 Sep 21, 2022
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022