diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..19546e0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = tab +indent_size = 4 diff --git a/.gitignore b/.gitignore index 44a5a83..6b145ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -.idea -.gradle -build -classes \ No newline at end of file +.idea +.gradle +/build +/classes + diff --git a/korge-coffee/.gitignore b/korge-coffee/.gitignore new file mode 100644 index 0000000..31f20e3 --- /dev/null +++ b/korge-coffee/.gitignore @@ -0,0 +1,2 @@ +/build +/genresources diff --git a/korge-coffee/build.gradle b/korge-coffee/build.gradle new file mode 100644 index 0000000..7b5a3c2 --- /dev/null +++ b/korge-coffee/build.gradle @@ -0,0 +1,42 @@ +apply from: "../include.gradle" + +apply plugin: 'kotlin' +apply plugin: 'application' + +mainClassName = "com.soywiz.korge.games.coffee.KorgeCoffeeModule" + +sourceSets { + generated.resources.srcDirs = [ 'genresources' ] + + main.kotlin.srcDirs = [ 'src' ] + main.resources.srcDirs = [ 'resources', 'genresources' ] + test.kotlin.srcDirs = [ 'test' ] +} + + +dependencies { + compile "com.soywiz:korge:$korVersion" + compile "com.soywiz:korge-ext-swf:$korVersion" + compile "com.soywiz:korau-mp3:$korVersion" + + nojtransc "com.soywiz:korge-ext-swf:$korVersion" + nojtransc "com.soywiz:korau-mp3:$korVersion" +} + +jtransc { + minimizeNames = true + treeshaking = true + + assets("resources") + assets("genresources") + + skipServiceLoader("com.soywiz.korim.format.JPEG") + skipServiceLoader("com.soywiz.korim.format.PNG") + + skipServiceLoader("com.soywiz.korau.format.MP3") + skipServiceLoader("com.soywiz.korau.format.OGG") +} + +jar.enabled = false +distTar.enabled = false +distZip.enabled = false diff --git a/korge-coffee/resources/icon.fla b/korge-coffee/resources/icon.fla new file mode 100644 index 0000000..d39843b Binary files /dev/null and b/korge-coffee/resources/icon.fla differ diff --git a/korge-coffee/resources/icon.png b/korge-coffee/resources/icon.png new file mode 100644 index 0000000..76b22d0 Binary files /dev/null and b/korge-coffee/resources/icon.png differ diff --git a/korge-coffee/resources/icon.swf b/korge-coffee/resources/icon.swf new file mode 100644 index 0000000..575fda1 Binary files /dev/null and b/korge-coffee/resources/icon.swf differ diff --git a/korge-coffee/resources/index.html b/korge-coffee/resources/index.html new file mode 100644 index 0000000..4015def --- /dev/null +++ b/korge-coffee/resources/index.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/korge-coffee/resources/main.fla b/korge-coffee/resources/main.fla new file mode 100644 index 0000000..ab9c6dc Binary files /dev/null and b/korge-coffee/resources/main.fla differ diff --git a/korge-coffee/resources/main.swf b/korge-coffee/resources/main.swf new file mode 100644 index 0000000..a3cb165 Binary files /dev/null and b/korge-coffee/resources/main.swf differ diff --git a/korge-coffee/resources/main.swf.config b/korge-coffee/resources/main.swf.config new file mode 100644 index 0000000..e6b969d --- /dev/null +++ b/korge-coffee/resources/main.swf.config @@ -0,0 +1,2 @@ +mipmaps = true +exportScale = 2.0 diff --git a/korge-coffee/src/com/soywiz/korge/games/coffee/main.kt b/korge-coffee/src/com/soywiz/korge/games/coffee/main.kt new file mode 100644 index 0000000..e61e45d --- /dev/null +++ b/korge-coffee/src/com/soywiz/korge/games/coffee/main.kt @@ -0,0 +1,147 @@ +package com.soywiz.korge.games.coffee + +import com.soywiz.korge.Korge +import com.soywiz.korge.animate.AnLibrary +import com.soywiz.korge.component.docking.jekllyButton +import com.soywiz.korge.resources.Path +import com.soywiz.korge.scene.* +import com.soywiz.korge.service.Browser +import com.soywiz.korge.time.seconds +import com.soywiz.korge.time.sleep +import com.soywiz.korge.tween.Easing +import com.soywiz.korge.tween.get +import com.soywiz.korge.tween.tween +import com.soywiz.korge.view.Camera +import com.soywiz.korge.view.Container +import com.soywiz.korge.view.camera +import com.soywiz.korge.view.get +import com.soywiz.korim.color.ColorTransform +import com.soywiz.korio.async.AsyncSignal +import com.soywiz.korio.async.go +import com.soywiz.korio.inject.Singleton +import java.net.URL + +object KorgeCoffeeModule : Module() { + @JvmStatic fun main(args: Array) = Korge(this@KorgeCoffeeModule) + + override val title: String = "KorGE Coffee" + override val mainScene: Class = MainScene::class.java + override val width: Int = (720 * 0.75).toInt() + override val height: Int = (1280 * 0.75).toInt() + override val virtualHeight: Int = 1280 + override val virtualWidth: Int = 720 + override val icon: String = "icon.png" + + object StartMessage + //object CloseCredits + + @Singleton + class LibraryContainer( + @Path("main.ani") val library: AnLibrary + ) + + class CreditsScene( + val lib: LibraryContainer, + val browser: Browser + ) : Scene() { + suspend override fun sceneInit(sceneView: Container) { + sceneView += lib.library.createMovieClip("Credits") + sceneView["korge"].jekllyButton(1.2).onClick { browser.browse(URL("http://korge.soywiz.com/")) } + sceneView["kotlin"].jekllyButton(1.2).onClick { browser.browse(URL("https://kotlinlang.org/")) } + sceneView["animate"].jekllyButton(1.2).onClick { browser.browse(URL("http://www.adobe.com/products/animate.html")) } + sceneView["github"].jekllyButton(1.2).onClick { browser.browse(URL("https://github.com/soywiz/korge-samples/tree/master/korge-coffee")) } + sceneView["soywiz"].jekllyButton(1.2).onClick { browser.browse(URL("http://soywiz.com/")) } + sceneView["tamy"].jekllyButton(1.2).onClick { browser.browse(URL("http://comic.tamy.es/")) } + sceneView["close"].jekllyButton(1.2).onClick { this.sceneContainer.back(time = 0.3.seconds) } + } + + suspend override fun sceneBeforeLeaving() { + super.sceneBeforeLeaving() + sceneView.mouseEnabled = false + } + } + + class MainMenuScene( + val lib: LibraryContainer + ) : Scene() { + lateinit var creditsSC: SceneContainer + val onStart = AsyncSignal() + + suspend override fun sceneInit(sceneView: Container) { + sceneView += lib.library.createMovieClip("MainMenu") + creditsSC = views.sceneContainer() + sceneView += creditsSC + sceneView["playButton"].jekllyButton(1.2).onClick { + //bus.send(StartMessage) + onStart(Unit) + } + sceneView["creditsButton"].jekllyButton(1.2).onClick { + creditsSC.pushTo(time = 0.2.seconds) + } + //o { + // sleep(1.seconds) + // bus.send(StartMessage) + // + } + + suspend override fun sceneBeforeLeaving() { + super.sceneBeforeLeaving() + sceneView.mouseEnabled = false + } + } + + class MainScene( + val lib: LibraryContainer + ) : Scene() { + lateinit var camera: Camera + lateinit var mainMenuSC: SceneContainer + + //@BusHandler suspend fun handle(s: StartMessage) { + // //views.clearEachFrame = false + // go { + // mainMenuSC.changeTo(time = 1.seconds, transition = AlphaTransition.withEasing(Easing.EASE_OUT_QUAD)) + // } + // startGame() + // //views.clearEachFrame = true + //} + + suspend override fun sceneInit(sceneView: Container) { + camera = views.camera() + + sceneView += lib.library.createMovieClip("Cameras").apply { visible = false } + sceneView += camera.apply { + this += lib.library.createMovieClip("Ingame") + } + mainMenuSC = views.sceneContainer() + sceneView += mainMenuSC + val mainMenu = mainMenuSC.pushTo() + mainMenu.onStart { + go { + mainMenuSC.back(time = 1.seconds, transition = AlphaTransition.withEasing(Easing.EASE_OUT_QUAD)) + } + startGame() + } + //println(sceneView["action"]) + //println(sceneView["menuCamera"]?.getGlobalBounds()) + //println(sceneView["ingameCamera"]?.getGlobalBounds()) + + //println(camera.getLocalMatrixFittingView(sceneView["ingameCamera"]!!)) + camera.setTo(sceneView["menuCamera"]!!) + sceneView["action"]?.colorTransform = ColorTransform.Add(-255, -255, -255, 0) + } + + suspend fun startGame() { + go { + val action = sceneView["action"] + action?.tween(action::colorTransform[ColorTransform.Add(0, 0, 0, 0)], time = 5.seconds, easing = Easing.LINEAR) + } + camera.tweenTo(sceneView["showCamera"], time = 2.seconds, easing = Easing.EASE_IN_OUT_QUAD) + camera.sleep(0.5.seconds) + go { + val background = sceneView["background"] + background?.tween(background::alpha[1.0], time = 1.seconds, easing = Easing.EASE_OUT_ELASTIC) + } + camera.tweenTo(sceneView["ingameCamera"], time = 1.seconds, easing = Easing.EASE_OUT_ELASTIC) + } + } +} diff --git a/korge-tic-tac-toe/.gitignore b/korge-tic-tac-toe/.gitignore index 30e2d18..31f20e3 100644 --- a/korge-tic-tac-toe/.gitignore +++ b/korge-tic-tac-toe/.gitignore @@ -1 +1,2 @@ -genresources \ No newline at end of file +/build +/genresources diff --git a/settings.gradle b/settings.gradle index 67aaaaa..1b7e755 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,4 +2,5 @@ rootProject.name = 'korge-samples' include( 'korge-tic-tac-toe', + 'korge-coffee', )