• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿญ Candy Crush Clone

Candy Crush Clone

Kotlin KorGE Gradle Awesome Kotlin Badge

Screenshot

๐Ÿšง This is a work in progress match 3 game. It's ready to play but also a clean and simple example for Kotlin multiplatform game development with KorGE. In addition, it includes a test driven step-by-step guide for learning the game mechanics. Originally designed for a workshop on the JavaLand4Kids.

๐ŸŽฎ Run the game as WebApp

โญ Features

โญ Cross-platform
โญ Touch controls
โญ Support for custom skins
โญ Tested and documented
โญ Build to teach

๐Ÿ’ฟ Downloads

๐Ÿ“ฆ Candy-Crush-Clone-1.1.0_win.zip 9.81 MB [Windows]

๐Ÿ’ก Native x64 one-click exe - No Java required.

๐Ÿ“ฆ Candy-Crush-Clone-1.1.0_jar.zip 17,20 MB 17.2 MB [Platform independent]

๐Ÿ’ก Requires an installed Java JRE. Runs on Windows, Linux & Mac.

๐Ÿ“ฑ Candy-Crush-Clone-1.1.0.apk 9,46 MB [Android App]

๐Ÿ’ก Should run on every Android with at least 4.1 Jelly Bean.

๐ŸŒŽ Candy-Crush-Clone-1.1.0_web.zip 7,70 MB [Web App]

๐Ÿ’ก To run the downloaded webapp, start a webserver in the extracted folder.

โŒจ Controls

Click and drag a candy onto another neighbor to get a row of minimum 3 tiles.

Keys controls are only for debugging purpose:

  • H7 Switch to debug mode.
  • P Print game field data.
  • D Toggle tiles with debug letters.
  • S Shuffle game field.
  • R Reload level.
  • I Print Image data.

๐Ÿ‘จโ€๐Ÿซ Workshop

If you want to do the workshop check out the branch Javaland4Kids. In this state the game logic is missing and needs to be implemented. Therefore, the tests are separated into 8 easy steps (step1 - step8). Each step contains several tests. Code until a step is running green:

./gradlew  jvmTest

After every step, you can run the game to check your progress.

./gradlew  runJvm

๐Ÿงญ Overview

The game runs in a game loop in the GameFlow. The game logic and the model are separated from the rendering. This allows to test the game without a UI. A EventBus helps to decouple the components. For easy dependency injection the AsyncInjector is used.

Class Diagram

Class Diagram

Game Flow

Sequence Diagram

๐Ÿ›  Setup

You can open this project in IntelliJ IDEA by opening the folder or the build.gradle.kts file. For Windows, change all the ./gradlew for gradlew.bat. You should use Gradle 7.5 or greater and Java 8 or greater.

To upgrade to a newer KorGE, change the plugin version in gradle/libs.versions.toml.

๐Ÿ”Š Audio

To mute sounds you can change src/commonMain/kotlin/main.kt and set playSounds = false. Sounds and music can be also enabled in the game settings (โš™ gear icon).

๐Ÿ“œ MIT Licence

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.

Some game resources are not included in this MIT licence and provided by others. Please respect their royalty:

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.

More Repositories

1

boostnote-markdown-cheatsheet

๐Ÿ“‹ ๐Ÿ“˜ The missing one page markdown feature cheat sheet for Boostnote
283
star
2

impf-bot

๐Ÿ’‰๐Ÿค– Bot for the German "ImpfterminService - 116117"
Kotlin
154
star
3

HitKlack

๐ŸŽฎ Retro console game remake of Mephisto Hit Klack
Kotlin
26
star
4

HitKlack_LibGDX

๐ŸŽฎ Retro console game remake of Mephisto Hit Klack
Kotlin
25
star
5

MagicMaze-Island

๐Ÿ Magic Maze board game clone. Korge Game Jam 2020 contribution.
Kotlin
19
star
6

XSwing-Plus

๐ŸŽฎ XSwing Plus -A Free Open Source Arcade Game Remake
Java
16
star
7

github-plugin-registry-example

GitHub Package Registry template for a maven package
Java
12
star
8

mapstruct-metadata-example

Example setup that uses ASM to provide MapStruct mapping info on runtime
Java
7
star
9

CleanCodeDeveloperJournal

๐Ÿ““ Track your clean code developer progress - Vaadin 14 sample project
Java
6
star
10

Emoji-Font-to-SVG-Extractor

๐Ÿ˜ ๐Ÿ”€ Extract svg or png files for every font symbol
Python
4
star
11

Kotlin-1.4-In-Action

๐Ÿ“š Sources for my Kotlin 1.3 Presentation
Kotlin
4
star
12

exit-game-bomb-app

๐Ÿ’ฃโฐ Bomb App for an Exit Game
Kotlin
3
star
13

RoguyIsleMaze-Server

WebSocket Game Server for RoguyIsleMaze
Kotlin
3
star
14

stackoverflow-badge

๐ŸŽซ Stack Overflow SVG-Flair Badge Generator
JavaScript
3
star
15

Playnite-Library-Minifier

๐Ÿ—œ Minifies a Playnite game database
Kotlin
2
star
16

KoJaMatchUp

๐ŸŽฎ Multiplayer match up game
Kotlin
2
star
17

TopsyIcons

๐Ÿฑโ€๐Ÿ‰ HDIP redesigned flat icons for some tools
HTML
1
star
18

intellij-launcher

Kotlin script that launches the latest installed IntelliJ with a specified project
Kotlin
1
star
19

Citty-Escape-Karlsruhe

๐Ÿ”๐Ÿˆ Search your lost cat in Karlsruhe - A Scotland Yard board game adaption
Kotlin
1
star
20

IntelliJ-Launcher-n

๐Ÿš€Native Kotlin tool that launches the latest installed IntelliJ
Kotlin
1
star
21

Hospital

๐Ÿš‘ Arcade game - My very first video game
Java
1
star
22

i18n-formatter-intellij-plugin

๐Ÿ›  A plugin for Intellij IDEA which formats a message.Properties file
Java
1
star
23

eTicketAppMockup

๐Ÿ˜ A mockup UI of the eTicket Karlsruhe App
JavaScript
1
star
24

Arduino-Countdown-Timer

โฒ Countdown timer for Arduino and the SparkFun 7-Segment Serial Display controlled by REST
C++
1
star
25

lueck-spare-part-3d-model

๐Ÿฆพ Spare part 3D model for a the Steck LรœCK kids game
Python
1
star
26

the-tree

๐ŸŒณ The Tree - Sample game project for Kotlin KorGE talk
Kotlin
1
star
27

HotClack

๐ŸŽฎ My Global Game Jam 2017 Summit. 2D Arcade Game written with Kotlin and LibGDX
Kotlin
1
star
28

intellij-keyboard-fix

โŒจ โœ” Fixes the IntelliJ Bug on `extract method` by removing letter `ยต`
1
star
29

KotlinJsGameWishlist

Kotlin JS sample project which shows a Steam game wishlist
Kotlin
1
star
30

jce-chocolatey-package

Chocolatey package for the JCE (Unlimited Strength Java Cryptography Extension Policy Files)
1
star
31

PhraseAppPropSort

๐Ÿ›  Property sorting and formatting with the PhraseApp style
Kotlin
1
star