nmpp
44
.travis.yml
Normal file
@@ -0,0 +1,44 @@
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
language: java
|
||||
jdk: oraclejdk8
|
||||
env: KBUILD=linux
|
||||
install:
|
||||
- nvm install 8
|
||||
- nvm use 8
|
||||
- node --version
|
||||
- npm -g install mocha
|
||||
- which node
|
||||
- which mocha
|
||||
script:
|
||||
- ./gradlew -s -i check build
|
||||
- os: windows
|
||||
env: KBUILD=windows
|
||||
language: shell # java is not supported but jdk is installed
|
||||
script:
|
||||
- powershell -Command "cmd /c travis_win.bat"
|
||||
- os: osx
|
||||
env: KBUILD=macos
|
||||
language: java
|
||||
jdk: oraclejdk8
|
||||
install:
|
||||
- nvm install 8
|
||||
- nvm use 8
|
||||
- node --version
|
||||
- npm -g install mocha
|
||||
- which node
|
||||
- which mocha
|
||||
script:
|
||||
- ./gradlew -s -i check build
|
||||
|
||||
#before_cache:
|
||||
# - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||
# - rm -f $HOME/.gradle-linux/caches/modules-2/modules-2.lock
|
||||
# - rm -f $HOME/.gradle-win/caches/modules-2/modules-2.lock
|
||||
#
|
||||
#cache:
|
||||
# directories:
|
||||
# - $HOME/.gradle/caches/
|
||||
# - $HOME/.gradle/wrapper/
|
||||
# - $HOME/.konan
|
||||
268
build.gradle
@@ -1,115 +1,201 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||
classpath "com.soywiz:korge-gradle-plugin:$korVersion"
|
||||
}
|
||||
|
||||
ext {
|
||||
libraries = [
|
||||
kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
|
||||
kotlin_stdlib_jvm : "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
|
||||
kotlin_stdlib_js : "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
|
||||
|
||||
kotlin_test_common : "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
|
||||
kotlin_test_jvm : "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
|
||||
kotlin_test_js : "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
|
||||
|
||||
kotlin_reflect : "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
provided
|
||||
plugins {
|
||||
id 'kotlin-multiplatform' version '1.3.0-rc-146'
|
||||
id 'com.moowork.node' version '1.2.0'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
configurations {
|
||||
provided
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://dl.bintray.com/soywiz/soywiz" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
|
||||
jcenter()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
it.afterEvaluate {
|
||||
if (it.plugins.hasPlugin("kotlin-platform-common")) {
|
||||
dependencies {
|
||||
compile libraries.kotlin_stdlib_common
|
||||
testCompile libraries.kotlin_test_common
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
experimental { coroutines 'enable' }
|
||||
}
|
||||
}
|
||||
if (it.plugins.hasPlugin("kotlin-platform-jvm") || it.plugins.hasPlugin("kotlin")) {
|
||||
dependencies {
|
||||
compile libraries.kotlin_stdlib_jvm
|
||||
testCompile libraries.kotlin_test_jvm
|
||||
testCompile "junit:junit:4.12"
|
||||
}
|
||||
subprojects {
|
||||
apply plugin: 'kotlin-multiplatform'
|
||||
apply plugin: 'com.moowork.node'
|
||||
|
||||
kotlin {
|
||||
experimental { coroutines 'enable' }
|
||||
}
|
||||
}
|
||||
if (it.plugins.hasPlugin("kotlin-platform-js") || it.plugins.hasPlugin("kotlin2js")) {
|
||||
dependencies {
|
||||
compile libraries.kotlin_stdlib_js
|
||||
testCompile libraries.kotlin_test_js
|
||||
}
|
||||
kotlin {
|
||||
targets {
|
||||
//fromPreset(presets.iosX64, 'iosX64')
|
||||
//fromPreset(presets.iosArm32, 'iosArm32')
|
||||
//fromPreset(presets.iosArm64, 'iosArm64')
|
||||
fromPreset(presets.macosX64, 'macosX64')
|
||||
//fromPreset(presets.linuxX64, 'linuxX64')
|
||||
fromPreset(presets.mingwX64, 'mingwX64')
|
||||
fromPreset(presets.jvm, 'jvm')
|
||||
fromPreset(presets.js, 'js') {
|
||||
compilations.main {
|
||||
compileKotlinJs.kotlinOptions {
|
||||
languageVersion = "1.3"
|
||||
sourceMap = true
|
||||
metaInfo = true
|
||||
moduleKind = "umd"
|
||||
}
|
||||
compileTestKotlinJs.kotlinOptions {
|
||||
languageVersion = "1.3"
|
||||
moduleKind = "commonjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
nonNativeCommonMain
|
||||
nativeCommonMain
|
||||
nativeCommonTest
|
||||
nativePosixMain
|
||||
configure([jvmMain, jsMain]) {
|
||||
dependsOn nonNativeCommonMain
|
||||
}
|
||||
mingwX64Main {
|
||||
dependsOn nativeCommonMain
|
||||
}
|
||||
mingwX64Test {
|
||||
dependsOn nativeCommonTest
|
||||
}
|
||||
//configure([iosX64Main, iosArm32Main, iosArm64Main, macosX64Main, linuxX64Main]) {
|
||||
configure([macosX64Main]) {
|
||||
dependsOn nativeCommonMain
|
||||
dependsOn nativePosixMain
|
||||
}
|
||||
//configure([iosX64Test, iosArm32Test, iosArm64Test, macosX64Test, linuxX64Test]) {
|
||||
configure([macosX64Test]) {
|
||||
dependsOn nativeCommonTest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
experimental { coroutines 'enable' }
|
||||
}
|
||||
dependencies {
|
||||
commonMainImplementation "org.jetbrains.kotlin:kotlin-stdlib-common"
|
||||
commonTestImplementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
|
||||
commonTestImplementation "org.jetbrains.kotlin:kotlin-test-common"
|
||||
|
||||
compileKotlin2Js {
|
||||
kotlinOptions.moduleKind = "umd"
|
||||
kotlinOptions.sourceMap = true
|
||||
}
|
||||
jsMainImplementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
||||
jsTestImplementation "org.jetbrains.kotlin:kotlin-test-js"
|
||||
|
||||
jvmMainImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
jvmTestImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||
jvmTestImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
||||
}
|
||||
|
||||
compileKotlin2Js {
|
||||
kotlinOptions.outputFile = "${projectDir}/web/output.js"
|
||||
kotlinOptions.sourceMap = false
|
||||
}
|
||||
// Javascript test configuration
|
||||
node {
|
||||
version = '8.11.4'
|
||||
download = true
|
||||
nodeModulesDir = file("$buildDir/yarn")
|
||||
}
|
||||
|
||||
clean {
|
||||
delete new File("${projectDir}/web")
|
||||
}
|
||||
def jsCompilations = kotlin.targets.js.compilations
|
||||
task addYarnDeps(type: YarnTask) {
|
||||
doFirst {
|
||||
mkdir "$buildDir/yarn"
|
||||
}
|
||||
args = ["add", "mocha@5.2.0"]
|
||||
}
|
||||
|
||||
compileKotlin2Js.doLast {
|
||||
configurations.compile.each { File file ->
|
||||
copy {
|
||||
includeEmptyDirs = false
|
||||
task populateNodeModules {
|
||||
doLast {
|
||||
copy {
|
||||
from "$buildDir/yarn/node_modules"
|
||||
from jsCompilations.main.output.first()
|
||||
jsCompilations.test.runtimeDependencyFiles.each {
|
||||
if (it.exists() && !it.isDirectory()) {
|
||||
from zipTree(it.absolutePath).matching { include '*.js' }
|
||||
}
|
||||
}
|
||||
into "$buildDir/node_modules"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from zipTree(file.absolutePath)
|
||||
into "${projectDir}/web"
|
||||
include { fileTreeElement ->
|
||||
def path = fileTreeElement.path
|
||||
(path.endsWith(".js") || path.endsWith(".js.map")) && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
task runMocha(type: NodeTask, dependsOn: [jsCompilations.test.compileKotlinTaskName, addYarnDeps, populateNodeModules]) {
|
||||
script = file("$buildDir/node_modules/mocha/bin/mocha")
|
||||
args = [relativePath("${jsCompilations.test.output.first()}/${project.name}_test.js")]
|
||||
}
|
||||
|
||||
copy {
|
||||
from sourceSets.main.resources.srcDirs
|
||||
into "${projectDir}/web"
|
||||
}
|
||||
}
|
||||
jsTest.dependsOn runMocha
|
||||
|
||||
jar.enabled = false
|
||||
// Fix for https://github.com/srs/gradle-node-plugin/issues/301
|
||||
repositories.whenObjectAdded {
|
||||
if (it instanceof IvyArtifactRepository) {
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Publishing
|
||||
group 'com.soywiz'
|
||||
version projectVersion
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
def pomBaseData = {
|
||||
licenses {
|
||||
license {
|
||||
name "MIT License"
|
||||
url "https://raw.githubusercontent.com/korlibs/korge-samples/master/LICENSE"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url "https://github.com/korlibs/korge-samples"
|
||||
}
|
||||
}
|
||||
|
||||
def generatePom = { pom ->
|
||||
pom.withXml {
|
||||
def root = it.asNode()
|
||||
root.appendNode('name', project.name)
|
||||
root.appendNode('description', 'Multiplatform Game Engine written in Kotlin (JVM, JS, Native and COMMON)')
|
||||
root.appendNode('url', 'https://github.com/korlibs/korge-samples')
|
||||
root.children().last() + pomBaseData
|
||||
}
|
||||
}
|
||||
|
||||
ext.generatePom = generatePom
|
||||
|
||||
def publishUser = rootProject.findProperty('BINTRAY_USER') ?: project.findProperty('bintrayUser') ?: System.getenv('BINTRAY_USER')
|
||||
def publishPassword = rootProject.findProperty('BINTRAY_KEY') ?: project.findProperty('bintrayApiKey') ?: System.getenv('BINTRAY_API_KEY')
|
||||
|
||||
if (publishUser && publishPassword) {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
credentials {
|
||||
username publishUser
|
||||
password publishPassword
|
||||
}
|
||||
url 'https://api.bintray.com/maven/soywiz/soywiz/korlibs/'
|
||||
//url "https://api.bintray.com/content/soywiz/soywiz/korlibs/$projectVersion"
|
||||
}
|
||||
}
|
||||
|
||||
configure(publications) {
|
||||
generatePom(pom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'idea'
|
||||
|
||||
idea {
|
||||
module {
|
||||
excludeDirs = [file(".gradle")]
|
||||
[
|
||||
".idea",
|
||||
"@old",
|
||||
"docs",
|
||||
"korge-samples-build",
|
||||
"korge-samples-samples",
|
||||
"korge-samples-intellij-plugin",
|
||||
"korge-samples-gradle-plugin",
|
||||
"korge-samples-flash-plugin",
|
||||
|
||||
].each {
|
||||
excludeDirs << file("$it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
korVersion=0.14.0
|
||||
jtranscVersion=0.6.7
|
||||
kotlinVersion=1.2.0-beta-31
|
||||
vertxVersion=3.4.2
|
||||
# sytleguide
|
||||
kotlin.code.style=official
|
||||
|
||||
# version
|
||||
projectVersion=0.0.1-SNAPSHOT
|
||||
|
||||
# external versions
|
||||
joglVersion=2.3.2
|
||||
gluegenVersion=2.3.2
|
||||
|
||||
# versions
|
||||
korgeVersion=0.5.0
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
11
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
||||
#Sun Aug 27 17:47:24 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
6
gradlew
vendored
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
@@ -155,7 +155,7 @@ if $cygwin ; then
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save ( ) {
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
|
||||
8
gradlew_linux
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
docker run \
|
||||
"-v$PWD:/work" \
|
||||
"-v$HOME/.gradle-linux:/root/.gradle" \
|
||||
"-v$HOME/.m2:/root/.m2" \
|
||||
"-v$HOME/.konan:/root/.konan" \
|
||||
soywiz/kotlin-native-win \
|
||||
./gradlew $*
|
||||
10
gradlew_win
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
HOME=`echo ~`
|
||||
|
||||
docker run -it \
|
||||
"-v$PWD:/work" \
|
||||
"-v$HOME/.gradle-win:/root/.wine/drive_c/users/root/.gradle" \
|
||||
"-v$HOME/.m2:/root/.wine/drive_c/users/root/.m2" \
|
||||
"-v$HOME/.konan:/root/.wine/drive_c/users/root/.konan" \
|
||||
soywiz/kotlin-native-win \
|
||||
winecmd gradlew.bat $*
|
||||
2
gradlew_wine
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
WINEDEBUG=-all wine cmd /c gradlew.bat $*
|
||||
6
korge-coffee/common/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
@@ -1,48 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
|
||||
//mainClassName = "com.soywiz.korge.games.coffee.KorgeCoffeeModule"
|
||||
|
||||
sourceSets {
|
||||
//generated.resources.srcDirs = ['src/generated/resources']
|
||||
//main.resources.srcDirs = [ 'src/main/resources' ]
|
||||
main.resources.srcDirs = [ 'src/main/resources', 'src/generated/resources' ]
|
||||
}
|
||||
|
||||
//sourceSets {
|
||||
// generated.resources.srcDirs = [ 'genresources' ]
|
||||
//
|
||||
// main.kotlin.srcDirs = [ 'src' ]
|
||||
// main.resources.srcDirs = [ 'resources', 'genresources' ]
|
||||
// test.kotlin.srcDirs = [ 'test' ]
|
||||
//}
|
||||
|
||||
|
||||
dependencies {
|
||||
compile "com.soywiz:korge-common:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf-common:$korVersion"
|
||||
compile "com.soywiz:korau-mp3-common:$korVersion"
|
||||
|
||||
//nojtransc "com.soywiz:korge-ext-swf:$korVersion"
|
||||
//nojtransc "com.soywiz:korau-mp3:$korVersion"
|
||||
}
|
||||
|
||||
/*
|
||||
jtransc {
|
||||
minimizeNames = true
|
||||
//minimizeNames = false
|
||||
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
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-coffee-common'
|
||||
|
Before Width: | Height: | Size: 54 KiB |
@@ -1 +0,0 @@
|
||||
{"name":"icon.swf","loaderVersion":16,"sha1":"9cdde618c8d67a214d0c8dddcbeec0bd668191ec","configSha1":""}
|
||||
|
Before Width: | Height: | Size: 736 KiB |
@@ -1 +0,0 @@
|
||||
{"name":"main.swf","loaderVersion":16,"sha1":"868c170d4f89f18fdcc12f91e731753ec55d3976","configSha1":"56181ca92b60e35d04d35cb4e32175ef5953c435"}
|
||||
@@ -1,489 +0,0 @@
|
||||
package com.soywiz.korge.games.coffee
|
||||
|
||||
import com.soywiz.korge.Korge
|
||||
import com.soywiz.korge.animate.*
|
||||
import com.soywiz.korge.bitmapfont.BitmapFont
|
||||
import com.soywiz.korge.component.docking.jellyButton
|
||||
import com.soywiz.korge.event.addEventListener
|
||||
import com.soywiz.korge.input.mouse
|
||||
import com.soywiz.korge.resources.getPath
|
||||
import com.soywiz.korge.scene.*
|
||||
import com.soywiz.korge.service.Browser
|
||||
import com.soywiz.korge.service.storage.Storage
|
||||
import com.soywiz.korge.service.storage.item
|
||||
import com.soywiz.korge.time.TimeSpan
|
||||
import com.soywiz.korge.time.seconds
|
||||
import com.soywiz.korge.time.sleep
|
||||
import com.soywiz.korge.tween.*
|
||||
import com.soywiz.korge.view.*
|
||||
import com.soywiz.korim.color.ColorTransform
|
||||
import com.soywiz.korio.async.AsyncSignal
|
||||
import com.soywiz.korio.async.Promise
|
||||
import com.soywiz.korio.async.go
|
||||
import com.soywiz.korio.inject.AsyncInjector
|
||||
import com.soywiz.korio.inject.InjectorAsyncDependency
|
||||
import com.soywiz.korio.inject.Optional
|
||||
import com.soywiz.korio.inject.Singleton
|
||||
import com.soywiz.korio.lang.JvmStatic
|
||||
import com.soywiz.korio.util.closeable
|
||||
import com.soywiz.korma.geom.Anchor
|
||||
import com.soywiz.korma.geom.Point2d
|
||||
import com.soywiz.korma.geom.SizeInt
|
||||
import com.soywiz.korma.random.MtRand
|
||||
import com.soywiz.korma.random.get
|
||||
import kotlin.math.max
|
||||
|
||||
@Suppress("unused")
|
||||
object KorgeCoffeeModule : Module() {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) = Korge(KorgeCoffeeModule, injector = AsyncInjector().prepareKoffee())
|
||||
|
||||
fun AsyncInjector.prepareKoffee() = this.apply {
|
||||
mapSingleton { Storage() }
|
||||
mapSingleton { com.soywiz.korge.service.Browser() }
|
||||
mapSingleton { GameStorage(get(Storage::class)) }
|
||||
mapSingleton { LibraryContainer() }
|
||||
mapPrototype { CreditsScene(get(LibraryContainer::class), get(Browser::class), get(GameStorage::class)) }
|
||||
mapPrototype { MainMenuScene(get(LibraryContainer::class), get(GameStorage::class)) }
|
||||
mapPrototype { MainScene(get(LibraryContainer::class), getOrNull(com.soywiz.korge.games.coffee.KorgeCoffeeModule.MainScene.State::class), get(GameStorage::class)) }
|
||||
}
|
||||
|
||||
object MainDebug {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) = Korge(KorgeCoffeeModule, sceneClass = MainScene::class, injector = AsyncInjector().prepareKoffee(), sceneInjects = listOf(MainScene.State.MAIN_MENU), debug = true)
|
||||
}
|
||||
|
||||
// Go directly to ingame to avoid testing main menu
|
||||
object IngameDebug {
|
||||
//@JvmStatic fun main(args: Array<String>) = Korge.invoke(KorgeCoffeeModule, sceneClass = MainScene::class.java, sceneInjects = listOf(MainScene.State.INGAME), debug = true)
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) = Korge.invoke(KorgeCoffeeModule, sceneClass = MainScene::class, injector = AsyncInjector().prepareKoffee(), sceneInjects = listOf(MainScene.State.INGAME), debug = false)
|
||||
}
|
||||
|
||||
override val title: String = "KorGE Coffee"
|
||||
override val mainScene = MainScene::class
|
||||
override val size: SizeInt = SizeInt(720, 1280)
|
||||
override val windowSize: SizeInt = size * 0.75
|
||||
override val icon: String = "icon.png"
|
||||
override val plugins = super.plugins + listOf(
|
||||
AnLibraryPlugin
|
||||
)
|
||||
|
||||
@Singleton
|
||||
class GameStorage(
|
||||
val storage: Storage
|
||||
) {
|
||||
var HiScore by storage.item("HiScore") { 0 }
|
||||
}
|
||||
|
||||
suspend override fun init(injector: AsyncInjector) {
|
||||
injector.get<Views>().registerPropertyTriggerSuspend("disabled") { view, key, value ->
|
||||
view.mouseEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
class LibraryContainer : InjectorAsyncDependency {
|
||||
lateinit var font: BitmapFont; private set
|
||||
lateinit var library: AnLibrary; private set
|
||||
|
||||
suspend override fun init(injector: AsyncInjector) {
|
||||
font = injector.getPath(BitmapFont::class, "font.fnt")
|
||||
library = injector.getPath(AnLibrary::class, "main.ani")
|
||||
}
|
||||
}
|
||||
|
||||
class CreditsScene(
|
||||
val libraryContainer: LibraryContainer,
|
||||
val browser: Browser,
|
||||
val gameStorage: GameStorage
|
||||
) : Scene() {
|
||||
val lib = libraryContainer.library
|
||||
suspend override fun sceneInit(sceneView: Container) {
|
||||
sceneView += lib.createMovieClip("Credits")
|
||||
sceneView["korge"].jellyButton(1.2).onClick { browser.browse("http://korge.soywiz.com/") }
|
||||
sceneView["kotlin"].jellyButton(1.2).onClick { browser.browse("https://kotlinlang.org/") }
|
||||
sceneView["animate"].jellyButton(1.2).onClick { browser.browse("http://www.adobe.com/products/animate.html") }
|
||||
sceneView["github"].jellyButton(1.2).onClick { browser.browse("https://github.com/soywiz/korge-samples/tree/master/korge-coffee") }
|
||||
sceneView["soywiz"].jellyButton(1.2).onClick { browser.browse("https://blog.soywiz.com/") }
|
||||
sceneView["tamy"].jellyButton(1.2).onClick { browser.browse("https://tamy.es/") }
|
||||
sceneView["close"].jellyButton(1.2).onClick { this.sceneContainer.back(time = 0.3.seconds) }
|
||||
}
|
||||
|
||||
suspend override fun sceneBeforeLeaving() {
|
||||
super.sceneBeforeLeaving()
|
||||
sceneView.mouseEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
class MainMenuScene(
|
||||
val libraryContainer: LibraryContainer,
|
||||
val gameStorage: GameStorage
|
||||
) : Scene() {
|
||||
val lib = libraryContainer.library
|
||||
lateinit var creditsSC: SceneContainer
|
||||
val onStart = AsyncSignal<Unit>()
|
||||
|
||||
suspend override fun sceneInit(sceneView: Container) {
|
||||
sceneView += lib.createMovieClip("MainMenu")
|
||||
creditsSC = views.sceneContainer()
|
||||
sceneView += creditsSC
|
||||
sceneView["playButton"].jellyButton(1.2).onClick {
|
||||
onStart(Unit)
|
||||
}
|
||||
sceneView["creditsButton"].jellyButton(1.2).onClick {
|
||||
creditsSC.pushTo<CreditsScene>(time = 0.2.seconds)
|
||||
}
|
||||
sceneView["hiscore"].setText("${gameStorage.HiScore}")
|
||||
}
|
||||
|
||||
suspend override fun sceneBeforeLeaving() {
|
||||
super.sceneBeforeLeaving()
|
||||
sceneView.mouseEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
class MainScene(
|
||||
val lib: LibraryContainer,
|
||||
@Optional val initialState: State?,
|
||||
val gameStorage: GameStorage
|
||||
) : Scene() {
|
||||
enum class State { MAIN_MENU, INGAME }
|
||||
|
||||
lateinit var camera: Camera
|
||||
lateinit var hud: View
|
||||
lateinit var ingame: View
|
||||
lateinit var mainMenuSC: SceneContainer
|
||||
|
||||
private suspend fun openMainMenu(transition: Boolean, callback: suspend () -> Unit) {
|
||||
hud.alpha = 0.0
|
||||
val mainMenu = mainMenuSC.pushTo<MainMenuScene>()
|
||||
mainMenu.onStart {
|
||||
callback()
|
||||
}
|
||||
if (transition) {
|
||||
camera.tweenTo(
|
||||
sceneView["menuCamera"]!!,
|
||||
sceneView["action"]!!::colorTransform[ColorTransform.Add(-255, -255, -255, 0)],
|
||||
time = 0.5.seconds, easing = Easing.EASE_OUT_QUAD
|
||||
)
|
||||
} else {
|
||||
camera.setTo(sceneView["menuCamera"]!!)
|
||||
sceneView["action"]?.colorTransform = ColorTransform.Add(-255, -255, -255, 0)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun closeMainMenu() {
|
||||
go {
|
||||
mainMenuSC.back(time = 1.seconds, transition = AlphaTransition.withEasing(Easing.EASE_OUT_QUAD))
|
||||
}
|
||||
}
|
||||
|
||||
suspend override fun sceneInit(sceneView: Container) {
|
||||
camera = views.camera()
|
||||
|
||||
sceneView += lib.library.createMovieClip("Cameras").apply { visible = false }
|
||||
sceneView += camera.apply {
|
||||
ingame = lib.library.createMovieClip("Ingame")
|
||||
this += ingame
|
||||
}
|
||||
hud = lib.library.createMovieClip("Hud")
|
||||
//(hud["scoreLabel"] as? AnTextField?)?.format = (hud["scoreLabel"] as? AnTextField?)?.format?.copy(face = Html.FontFace.Bitmap(lib.font))!!
|
||||
//(hud["scoreText"] as? AnTextField?)?.format = (hud["scoreText"] as? AnTextField?)?.format?.copy(face = Html.FontFace.Bitmap(lib.font))!!
|
||||
sceneView += hud
|
||||
mainMenuSC = views.sceneContainer()
|
||||
sceneView += mainMenuSC
|
||||
|
||||
when (initialState) {
|
||||
null, State.MAIN_MENU -> {
|
||||
hud.alpha = 0.0
|
||||
openMainMenu(transition = false) {
|
||||
closeMainMenu()
|
||||
startGame()
|
||||
doIngame()
|
||||
}
|
||||
}
|
||||
State.INGAME -> {
|
||||
camera.setTo(sceneView["ingameCamera"]!!)
|
||||
sceneView["action"]?.colorTransform = ColorTransform.Add(0, 0, 0, 0)
|
||||
sceneView["background"]?.alpha = 1.0
|
||||
doIngame()
|
||||
}
|
||||
}
|
||||
|
||||
sceneView["pauseButton"]?.mouseEnabled = false
|
||||
sceneView["pauseButton"].jellyButton(1.125).onClick {
|
||||
//sceneView["ingame"]?.speed = 0.0
|
||||
updateHiScore()
|
||||
ingame.speed = 0.0
|
||||
|
||||
val oldCamera = camera.localMatrix.copy()
|
||||
|
||||
openMainMenu(transition = true) {
|
||||
closeMainMenu()
|
||||
camera.tween(
|
||||
camera::localMatrix[oldCamera],
|
||||
sceneView["action"]!!::colorTransform[ColorTransform.Add(0, 0, 0, 0)],
|
||||
hud::alpha[1.0],
|
||||
time = 0.5.seconds, easing = Easing.EASE_OUT_QUAD
|
||||
)
|
||||
ingame.speed = 1.0
|
||||
}
|
||||
|
||||
//mainMenuSC.pushTo<MainMenuScene>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
suspend fun startGame() {
|
||||
allowSpeedUp {
|
||||
go {
|
||||
val action = sceneView["action"]
|
||||
action?.tween(action::colorTransform[ColorTransform.Add(0, 0, 0, 0)], time = 5.seconds, easing = Easing.LINEAR)
|
||||
}
|
||||
go {
|
||||
hud.tween(hud::alpha[1.0], time = 2.seconds, easing = Easing.LINEAR)
|
||||
}
|
||||
camera.tweenTo(sceneView["showCamera"], time = 2.seconds, easing = Easing.EASE_IN_OUT_QUAD)
|
||||
sceneView["messages"]?.speed = 0.7
|
||||
sceneView["messages"].playAndWaitEvent("tap", "tap_continue")
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
var score = 0
|
||||
|
||||
private fun updateScore() {
|
||||
sceneView["scoreText"].setText("$score")
|
||||
}
|
||||
|
||||
private fun incrementScore(delta: Int) {
|
||||
score += delta
|
||||
updateScore()
|
||||
}
|
||||
|
||||
private suspend fun incrementScore(view: View, delta: Int) {
|
||||
val scoreView = sceneView["score"] ?: views.container()
|
||||
//val entityHigh = sceneView["entityHigh"] ?: views.container()
|
||||
val entityHigh = sceneView["hudContainer"] ?: views.container()
|
||||
val text = views.text("+$delta", textSize = 16.0).apply { entityHigh += this }
|
||||
text.globalX = view.globalX
|
||||
text.globalY = view.globalY
|
||||
text.tween(
|
||||
text::globalX[scoreView.globalX],
|
||||
text::globalY[scoreView.globalY],
|
||||
text::alpha[0.0],
|
||||
time = 0.3.seconds
|
||||
)
|
||||
text.removeFromParent()
|
||||
scoreView.tween(
|
||||
scoreView::scale[0.7],
|
||||
time = 0.2.seconds,
|
||||
easing = Easing.EASE_OUT_ELASTIC
|
||||
)
|
||||
incrementScore(delta)
|
||||
scoreView.tween(
|
||||
scoreView::scale[1.0],
|
||||
time = 0.2.seconds,
|
||||
easing = Easing.EASE_OUT_ELASTIC
|
||||
)
|
||||
}
|
||||
|
||||
private val colorAddBlack = ColorTransform.Add(-255, -255, -255, 0).colorAdd
|
||||
private val colorAddNormal = ColorTransform.Add(0, 0, 0, 0).colorAdd
|
||||
|
||||
class DismissKotlinMessage(val givePoints: Boolean)
|
||||
|
||||
fun destroyAllEntities() {
|
||||
sceneView.dispatch(DismissKotlinMessage(givePoints = false))
|
||||
}
|
||||
|
||||
var spawner = Promise.resolved(Unit)
|
||||
var running = true
|
||||
|
||||
private fun updateHiScore() {
|
||||
gameStorage.HiScore = max(gameStorage.HiScore, score)
|
||||
}
|
||||
|
||||
suspend fun allowSpeedUp(callback: suspend () -> Unit) {
|
||||
val events = listOf(
|
||||
views.stage.mouse.onDown { sceneView.speed = 5.0 },
|
||||
views.stage.mouse.onUpAnywhere { sceneView.speed = 1.0 }
|
||||
).closeable()
|
||||
try {
|
||||
callback()
|
||||
} finally {
|
||||
events.close()
|
||||
sceneView.speed = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun gameOver() {
|
||||
allowSpeedUp {
|
||||
updateHiScore()
|
||||
sceneView["pauseButton"]?.alpha = 0.0
|
||||
destroyAllEntities()
|
||||
spawner.cancel()
|
||||
running = false
|
||||
camera.tweenTo(sceneView["showCamera"], time = 0.5.seconds, easing = Easing.EASE_OUT_ELASTIC)
|
||||
sceneView["action"].waitEvent("mainLoop")
|
||||
sceneView["action"].playAndWaitEvent("drop", "dropZoom")
|
||||
camera.tweenTo(sceneView["zoomCamera"], time = 0.5.seconds, easing = Easing.EASE_OUT_QUAD)
|
||||
sceneView["action"].waitStop()
|
||||
sceneView["messages"].playAndWaitStop("gameover")
|
||||
sceneView.sleep(1.seconds)
|
||||
sceneView.tween(sceneView::colorTransform[ColorTransform.Add(-255, -255, -255, 0)], time = 0.5.seconds)
|
||||
this.sceneContainer.changeTo<MainScene>(initialState ?: State.MAIN_MENU)
|
||||
//sceneView["action"].play("drop")
|
||||
}
|
||||
}
|
||||
|
||||
fun createEntity(globalPos: Point2d, scale: Double, reachTime: TimeSpan): View {
|
||||
val kotlinHigh = lib.library.createMovieClip("KotlinHigh")
|
||||
val kotlinLow = lib.library.createMovieClip("KotlinLow")
|
||||
val entityHigh = sceneView["entityHigh"] ?: views.container()
|
||||
val entityLow = sceneView["entityLow"] ?: views.container()
|
||||
entityHigh += kotlinHigh
|
||||
entityLow += kotlinLow
|
||||
// Synchronize low part with high part
|
||||
entityHigh.addUpdatable {
|
||||
kotlinLow.globalMatrix = kotlinHigh.globalMatrix
|
||||
kotlinLow.alpha = kotlinHigh.alpha
|
||||
kotlinLow.colorAdd = kotlinHigh.colorAdd
|
||||
}
|
||||
|
||||
val localDestination = kotlinHigh.globalToLocal(sceneView["rope"]!!.globalBounds.getAnchoredPosition(Anchor.MIDDLE_CENTER))
|
||||
|
||||
kotlinHigh.globalX = globalPos.x
|
||||
kotlinHigh.globalY = globalPos.y
|
||||
|
||||
var cancelled = false
|
||||
|
||||
val movePromise = go {
|
||||
kotlinHigh.tween(
|
||||
kotlinHigh::scale[0.8, scale],
|
||||
kotlinHigh::colorAdd[colorAddBlack, colorAddNormal].color(),
|
||||
time = 0.3.seconds
|
||||
)
|
||||
|
||||
//val distance = Math.hypot(globalDestination.x - kotlin.globalX, globalDestination.y - kotlin.globalY)
|
||||
|
||||
kotlinHigh.tween(
|
||||
kotlinHigh::x[localDestination.x],
|
||||
kotlinHigh::y[localDestination.y],
|
||||
kotlinHigh::scale[kotlinHigh.scale * 0.75].easeOutQuad(),
|
||||
//time = (distance * 5).milliseconds
|
||||
time = reachTime
|
||||
)
|
||||
|
||||
if (!cancelled) { // @TODO: Shouldn't be necessary since cancelling should cancell the whole process
|
||||
go {
|
||||
gameOver()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlinHigh.addEventListener<DismissKotlinMessage> {
|
||||
kotlinHigh.mouseEnabled = false
|
||||
cancelled = true
|
||||
movePromise.cancel()
|
||||
go {
|
||||
if (it.givePoints) {
|
||||
go {
|
||||
incrementScore(kotlinHigh, delta = +1)
|
||||
}
|
||||
}
|
||||
go {
|
||||
kotlinHigh.tween(
|
||||
kotlinHigh::colorAdd[colorAddBlack].color(),
|
||||
kotlinHigh::scale[0.0],
|
||||
time = 0.3.seconds
|
||||
)
|
||||
kotlinHigh.removeFromParent()
|
||||
kotlinLow.removeFromParent()
|
||||
//createEntity(x = random[0.0, 600.0 * 2], y = random[0.0, 1200.0 * 2], scale = 2.5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlinHigh.mouse.apply { hitTestType = View.HitTestType.SHAPE }.onDown {
|
||||
kotlinHigh.dispatch(DismissKotlinMessage(givePoints = true))
|
||||
}
|
||||
go {
|
||||
while (true) {
|
||||
kotlinHigh.tween(kotlinHigh::rotationDegrees[0, 360], time = 2.seconds)
|
||||
}
|
||||
}
|
||||
return kotlinHigh
|
||||
}
|
||||
|
||||
val random = MtRand()
|
||||
|
||||
data class DifficultyConfig(
|
||||
val spawnCount: Int = 2,
|
||||
val nextSpawnTime: ClosedRange<TimeSpan> = 1.seconds..1.seconds,
|
||||
val scale: ClosedRange<Double> = 2.5..2.5,
|
||||
val reachTime: ClosedRange<TimeSpan> = 2.seconds..2.seconds
|
||||
)
|
||||
|
||||
private fun buildDifficultyConfig(step: Int): DifficultyConfig {
|
||||
val spawnCount = when {
|
||||
step < 5 -> 1
|
||||
step < 20 -> random[listOf(1, 2)]
|
||||
step < 30 -> random[listOf(1, 2, 2)]
|
||||
step < 50 -> random[listOf(1, 2, 2, 2, 3)]
|
||||
else -> random[listOf(1, 2, 2, 2, 3, 3, 3, 3, 3, 3)]
|
||||
}
|
||||
|
||||
val reachTime = when {
|
||||
step < 50 -> 2.seconds
|
||||
else -> 1.5.seconds
|
||||
} * spawnCount
|
||||
|
||||
return DifficultyConfig(
|
||||
spawnCount = spawnCount,
|
||||
nextSpawnTime = when {
|
||||
step < 5 -> 1.8.seconds..2.2.seconds
|
||||
step < 10 -> 1.5.seconds..2.0.seconds
|
||||
step < 20 -> 1.seconds..1.5.seconds
|
||||
else -> 0.8.seconds..1.seconds
|
||||
},
|
||||
scale = when {
|
||||
step < 50 -> 2.5..2.5
|
||||
step < 100 -> 2.0..2.5
|
||||
step < 200 -> 1.5..2.0
|
||||
else -> 1.0..1.5
|
||||
},
|
||||
reachTime = reachTime..reachTime * 1.1
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun doSpawner() {
|
||||
val spawnZones = sceneView.descendantsWithProp("spawnZone")
|
||||
|
||||
var step = 0
|
||||
while (running) {
|
||||
val config = buildDifficultyConfig(step)
|
||||
for (n in 0 until config.spawnCount) {
|
||||
val point = random[random[spawnZones].globalBounds]
|
||||
createEntity(globalPos = point, scale = random[config.scale], reachTime = random[config.reachTime])
|
||||
}
|
||||
ingame.sleep(random[config.nextSpawnTime])
|
||||
step++
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun doIngame() {
|
||||
sceneView["pauseButton"]?.mouseEnabled = true
|
||||
spawner = go {
|
||||
doSpawner()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
<font>
|
||||
<info face="font" size="72" bold="0" italic="0" charset="" unicode="" stretchH="100" smooth="1" aa="1" padding="2,2,2,2" spacing="0,0" outline="0"/>
|
||||
<common lineHeight="80" base="57" scaleW="470" scaleH="512" pages="1" packed="0"/>
|
||||
<pages>
|
||||
<page id="0" file="font.png"/>
|
||||
</pages>
|
||||
<chars count="80">
|
||||
<char id="97" x="2" y="2" width="43" height="47" xoffset="3" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="98" x="2" y="51" width="41" height="61" xoffset="5" yoffset="5" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="99" x="2" y="114" width="41" height="47" xoffset="3" yoffset="18" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="100" x="2" y="163" width="41" height="61" xoffset="2" yoffset="5" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="101" x="2" y="226" width="43" height="47" xoffset="3" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="102" x="45" y="51" width="30" height="61" xoffset="1" yoffset="4" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="103" x="45" y="114" width="41" height="62" xoffset="2" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="104" x="77" y="2" width="39" height="60" xoffset="5" yoffset="5" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="105" x="2" y="275" width="15" height="60" xoffset="5" yoffset="5" xadvance="16" page="0" chnl="15"/>
|
||||
<char id="106" x="2" y="337" width="24" height="75" xoffset="-4" yoffset="5" xadvance="16" page="0" chnl="15"/>
|
||||
<char id="107" x="19" y="275" width="40" height="60" xoffset="5" yoffset="5" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="108" x="47" y="178" width="15" height="60" xoffset="5" yoffset="5" xadvance="16" page="0" chnl="15"/>
|
||||
<char id="109" x="77" y="64" width="59" height="47" xoffset="5" yoffset="18" xadvance="60" page="0" chnl="15"/>
|
||||
<char id="110" x="118" y="2" width="39" height="47" xoffset="5" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="111" x="2" y="414" width="43" height="47" xoffset="2" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="112" x="28" y="337" width="41" height="61" xoffset="5" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="113" x="61" y="240" width="41" height="61" xoffset="3" yoffset="18" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="114" x="2" y="463" width="29" height="47" xoffset="5" yoffset="18" xadvance="24" page="0" chnl="15"/>
|
||||
<char id="115" x="33" y="463" width="40" height="47" xoffset="2" yoffset="18" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="116" x="64" y="178" width="27" height="60" xoffset="1" yoffset="6" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="117" x="47" y="400" width="39" height="47" xoffset="5" yoffset="19" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="118" x="75" y="449" width="43" height="46" xoffset="1" yoffset="19" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="119" x="88" y="113" width="60" height="46" xoffset="0" yoffset="19" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="120" x="138" y="51" width="45" height="46" xoffset="0" yoffset="19" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="121" x="93" y="161" width="43" height="61" xoffset="1" yoffset="19" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="122" x="159" y="2" width="41" height="46" xoffset="1" yoffset="19" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="65" x="71" y="303" width="57" height="60" xoffset="0" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="66" x="104" y="224" width="47" height="60" xoffset="5" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="67" x="88" y="365" width="54" height="62" xoffset="4" yoffset="4" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="68" x="138" y="161" width="51" height="60" xoffset="6" yoffset="5" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="69" x="150" y="99" width="47" height="60" xoffset="6" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="70" x="130" y="286" width="43" height="60" xoffset="6" yoffset="5" xadvance="44" page="0" chnl="15"/>
|
||||
<char id="71" x="120" y="429" width="56" height="62" xoffset="4" yoffset="4" xadvance="56" page="0" chnl="15"/>
|
||||
<char id="72" x="153" y="223" width="49" height="60" xoffset="6" yoffset="5" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="73" x="191" y="161" width="15" height="60" xoffset="7" yoffset="5" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="74" x="144" y="348" width="37" height="61" xoffset="2" yoffset="5" xadvance="36" page="0" chnl="15"/>
|
||||
<char id="75" x="175" y="285" width="51" height="60" xoffset="5" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="76" x="204" y="223" width="41" height="60" xoffset="5" yoffset="5" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="77" x="178" y="411" width="58" height="60" xoffset="5" yoffset="5" xadvance="60" page="0" chnl="15"/>
|
||||
<char id="78" x="183" y="347" width="49" height="60" xoffset="5" yoffset="5" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="79" x="199" y="50" width="58" height="62" xoffset="3" yoffset="4" xadvance="56" page="0" chnl="15"/>
|
||||
<char id="80" x="228" y="285" width="48" height="60" xoffset="6" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="81" x="208" y="114" width="59" height="65" xoffset="3" yoffset="4" xadvance="56" page="0" chnl="15"/>
|
||||
<char id="82" x="234" y="347" width="54" height="60" xoffset="6" yoffset="5" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="83" x="238" y="409" width="49" height="62" xoffset="3" yoffset="4" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="84" x="289" y="409" width="49" height="60" xoffset="2" yoffset="5" xadvance="44" page="0" chnl="15"/>
|
||||
<char id="85" x="247" y="181" width="49" height="61" xoffset="6" yoffset="5" xadvance="52" page="0" chnl="15"/>
|
||||
<char id="86" x="278" y="244" width="56" height="60" xoffset="0" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="87" x="290" y="306" width="75" height="60" xoffset="1" yoffset="5" xadvance="68" page="0" chnl="15"/>
|
||||
<char id="88" x="259" y="2" width="56" height="60" xoffset="0" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="89" x="269" y="64" width="56" height="60" xoffset="0" yoffset="5" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="90" x="317" y="2" width="49" height="60" xoffset="1" yoffset="5" xadvance="44" page="0" chnl="15"/>
|
||||
<char id="33" x="298" y="126" width="16" height="60" xoffset="6" yoffset="5" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="8470" x="316" y="126" width="77" height="60" xoffset="6" yoffset="5" xadvance="77" page="0" chnl="15"/>
|
||||
<char id="59" x="327" y="64" width="16" height="56" xoffset="6" yoffset="19" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="37" x="336" y="188" width="64" height="63" xoffset="4" yoffset="4" xadvance="64" page="0" chnl="15"/>
|
||||
<char id="58" x="202" y="2" width="16" height="46" xoffset="7" yoffset="19" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="63" x="368" y="2" width="42" height="61" xoffset="3" yoffset="4" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="42" x="298" y="188" width="32" height="30" xoffset="2" yoffset="4" xadvance="28" page="0" chnl="15"/>
|
||||
<char id="40" x="395" y="65" width="25" height="76" xoffset="4" yoffset="4" xadvance="24" page="0" chnl="15"/>
|
||||
<char id="41" x="340" y="368" width="26" height="76" xoffset="4" yoffset="4" xadvance="24" page="0" chnl="15"/>
|
||||
<char id="95" x="75" y="497" width="50" height="13" xoffset="-1" yoffset="66" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="43" x="395" y="143" width="42" height="42" xoffset="4" yoffset="14" xadvance="42" page="0" chnl="15"/>
|
||||
<char id="45" x="47" y="2" width="28" height="15" xoffset="2" yoffset="34" xadvance="24" page="0" chnl="15"/>
|
||||
<char id="61" x="290" y="368" width="42" height="30" xoffset="4" yoffset="20" xadvance="42" page="0" chnl="15"/>
|
||||
<char id="46" x="144" y="411" width="16" height="16" xoffset="7" yoffset="49" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="44" x="47" y="19" width="16" height="26" xoffset="6" yoffset="49" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="47" x="340" y="446" width="29" height="62" xoffset="0" yoffset="4" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="124" x="367" y="253" width="14" height="76" xoffset="7" yoffset="4" xadvance="19" page="0" chnl="15"/>
|
||||
<char id="34" x="269" y="126" width="27" height="27" xoffset="3" yoffset="5" xadvance="26" page="0" chnl="15"/>
|
||||
<char id="39" x="345" y="64" width="16" height="27" xoffset="3" yoffset="5" xadvance="14" page="0" chnl="15"/>
|
||||
<char id="64" x="368" y="331" width="75" height="76" xoffset="4" yoffset="4" xadvance="73" page="0" chnl="15"/>
|
||||
<char id="35" x="383" y="253" width="47" height="62" xoffset="1" yoffset="4" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="36" x="371" y="409" width="42" height="72" xoffset="3" yoffset="0" xadvance="40" page="0" chnl="15"/>
|
||||
<char id="94" x="178" y="473" width="39" height="37" xoffset="2" yoffset="4" xadvance="34" page="0" chnl="15"/>
|
||||
<char id="38" x="402" y="187" width="52" height="62" xoffset="3" yoffset="4" xadvance="48" page="0" chnl="15"/>
|
||||
<char id="123" x="432" y="251" width="29" height="76" xoffset="2" yoffset="4" xadvance="24" page="0" chnl="15"/>
|
||||
<char id="125" x="415" y="409" width="29" height="76" xoffset="2" yoffset="4" xadvance="24" page="0" chnl="15"/>
|
||||
<char id="91" x="445" y="329" width="22" height="74" xoffset="5" yoffset="5" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="93" x="446" y="405" width="22" height="74" xoffset="1" yoffset="5" xadvance="20" page="0" chnl="15"/>
|
||||
<char id="32" x="0" y="0" width="0" height="0" xoffset="1" yoffset="5" xadvance="20" page="0" chnl="15"/>
|
||||
</chars>
|
||||
<kernings count="96">
|
||||
<kerning first="32" second="65" amount="-4"/>
|
||||
<kerning first="32" second="84" amount="-1"/>
|
||||
<kerning first="32" second="89" amount="-1"/>
|
||||
<kerning first="65" second="32" amount="-4"/>
|
||||
<kerning first="65" second="84" amount="-5"/>
|
||||
<kerning first="65" second="86" amount="-5"/>
|
||||
<kerning first="65" second="87" amount="-3"/>
|
||||
<kerning first="65" second="89" amount="-5"/>
|
||||
<kerning first="65" second="118" amount="-1"/>
|
||||
<kerning first="65" second="119" amount="-1"/>
|
||||
<kerning first="65" second="121" amount="-1"/>
|
||||
<kerning first="70" second="44" amount="-8"/>
|
||||
<kerning first="70" second="46" amount="-8"/>
|
||||
<kerning first="70" second="65" amount="-4"/>
|
||||
<kerning first="76" second="32" amount="-3"/>
|
||||
<kerning first="76" second="84" amount="-5"/>
|
||||
<kerning first="76" second="86" amount="-5"/>
|
||||
<kerning first="76" second="87" amount="-5"/>
|
||||
<kerning first="76" second="89" amount="-5"/>
|
||||
<kerning first="76" second="121" amount="-3"/>
|
||||
<kerning first="80" second="32" amount="-1"/>
|
||||
<kerning first="80" second="44" amount="-9"/>
|
||||
<kerning first="80" second="46" amount="-9"/>
|
||||
<kerning first="80" second="65" amount="-5"/>
|
||||
<kerning first="82" second="84" amount="-1"/>
|
||||
<kerning first="82" second="86" amount="-1"/>
|
||||
<kerning first="82" second="87" amount="-1"/>
|
||||
<kerning first="82" second="89" amount="-1"/>
|
||||
<kerning first="84" second="32" amount="-1"/>
|
||||
<kerning first="84" second="44" amount="-8"/>
|
||||
<kerning first="84" second="45" amount="-4"/>
|
||||
<kerning first="84" second="46" amount="-8"/>
|
||||
<kerning first="84" second="58" amount="-8"/>
|
||||
<kerning first="84" second="59" amount="-8"/>
|
||||
<kerning first="84" second="65" amount="-5"/>
|
||||
<kerning first="84" second="79" amount="-1"/>
|
||||
<kerning first="84" second="97" amount="-8"/>
|
||||
<kerning first="84" second="99" amount="-8"/>
|
||||
<kerning first="84" second="101" amount="-8"/>
|
||||
<kerning first="84" second="105" amount="-3"/>
|
||||
<kerning first="84" second="111" amount="-8"/>
|
||||
<kerning first="84" second="114" amount="-3"/>
|
||||
<kerning first="84" second="115" amount="-8"/>
|
||||
<kerning first="84" second="117" amount="-3"/>
|
||||
<kerning first="84" second="119" amount="-4"/>
|
||||
<kerning first="84" second="121" amount="-4"/>
|
||||
<kerning first="86" second="44" amount="-7"/>
|
||||
<kerning first="86" second="45" amount="-4"/>
|
||||
<kerning first="86" second="46" amount="-7"/>
|
||||
<kerning first="86" second="58" amount="-3"/>
|
||||
<kerning first="86" second="59" amount="-3"/>
|
||||
<kerning first="86" second="65" amount="-5"/>
|
||||
<kerning first="86" second="97" amount="-5"/>
|
||||
<kerning first="86" second="101" amount="-4"/>
|
||||
<kerning first="86" second="105" amount="-1"/>
|
||||
<kerning first="86" second="111" amount="-4"/>
|
||||
<kerning first="86" second="114" amount="-3"/>
|
||||
<kerning first="86" second="117" amount="-3"/>
|
||||
<kerning first="86" second="121" amount="-3"/>
|
||||
<kerning first="87" second="44" amount="-4"/>
|
||||
<kerning first="87" second="45" amount="-1"/>
|
||||
<kerning first="87" second="46" amount="-4"/>
|
||||
<kerning first="87" second="58" amount="-1"/>
|
||||
<kerning first="87" second="59" amount="-1"/>
|
||||
<kerning first="87" second="65" amount="-3"/>
|
||||
<kerning first="87" second="97" amount="-3"/>
|
||||
<kerning first="87" second="101" amount="-1"/>
|
||||
<kerning first="87" second="105" amount="0"/>
|
||||
<kerning first="87" second="111" amount="-1"/>
|
||||
<kerning first="87" second="114" amount="-1"/>
|
||||
<kerning first="87" second="117" amount="-1"/>
|
||||
<kerning first="87" second="121" amount="-1"/>
|
||||
<kerning first="89" second="32" amount="-1"/>
|
||||
<kerning first="89" second="44" amount="-9"/>
|
||||
<kerning first="89" second="45" amount="-7"/>
|
||||
<kerning first="89" second="46" amount="-9"/>
|
||||
<kerning first="89" second="58" amount="-4"/>
|
||||
<kerning first="89" second="59" amount="-5"/>
|
||||
<kerning first="89" second="65" amount="-5"/>
|
||||
<kerning first="89" second="97" amount="-5"/>
|
||||
<kerning first="89" second="101" amount="-7"/>
|
||||
<kerning first="89" second="105" amount="-3"/>
|
||||
<kerning first="89" second="111" amount="-7"/>
|
||||
<kerning first="89" second="112" amount="-5"/>
|
||||
<kerning first="89" second="113" amount="-7"/>
|
||||
<kerning first="89" second="117" amount="-4"/>
|
||||
<kerning first="89" second="118" amount="-4"/>
|
||||
<kerning first="102" second="102" amount="-1"/>
|
||||
<kerning first="114" second="44" amount="-4"/>
|
||||
<kerning first="114" second="46" amount="-4"/>
|
||||
<kerning first="118" second="44" amount="-5"/>
|
||||
<kerning first="118" second="46" amount="-5"/>
|
||||
<kerning first="119" second="44" amount="-4"/>
|
||||
<kerning first="119" second="46" amount="-4"/>
|
||||
<kerning first="121" second="44" amount="-5"/>
|
||||
<kerning first="121" second="46" amount="-5"/>
|
||||
</kernings>
|
||||
</font>
|
||||
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 64 KiB |
@@ -1,21 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
requirejs(['output'], function (app) {
|
||||
window.app = app;
|
||||
app.com.soywiz.korge.games.coffee.KorgeCoffeeModule.main_kand9s$([]);
|
||||
//app.com.soywiz.korio.example.MainJs.main()
|
||||
//app.Sample.main_kand9s$([]);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script src="program.js" type="text/javascript"></script>
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +0,0 @@
|
||||
mipmaps: true
|
||||
exportScale: 2.0
|
||||
adaptiveScaling: true
|
||||
smoothInterpolation: true
|
||||
maxShapeSide: 400
|
||||
maxTextureSide: 2048
|
||||
7
korge-coffee/js/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
/web
|
||||
@@ -1,21 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
//apply plugin: 'kotlin-dce-js'
|
||||
//runDceKotlinJs.keep "korge-coffee-js.com.soywiz.korge.games.coffee.KorgeCoffeeModule.main", "korge-coffee-js.com.soywiz.korge.games.coffee.KorgeCoffeeModule"
|
||||
|
||||
//apply plugin: 'application'
|
||||
|
||||
//mainClassName = "com.soywiz.korge.games.coffee.KorgeCoffeeModule"
|
||||
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(":korge-coffee:common")
|
||||
|
||||
compile "com.soywiz:korge-js:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf-js:$korVersion"
|
||||
compile "com.soywiz:korau-mp3-js:$korVersion"
|
||||
testCompile "com.soywiz:korge-tests-js:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-coffee-js'
|
||||
6
korge-coffee/jvm/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
@@ -1,18 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = "com.soywiz.korge.games.coffee.KorgeCoffeeModule"
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(":korge-coffee:common")
|
||||
|
||||
compile "com.soywiz:korge:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf:$korVersion"
|
||||
compile "com.soywiz:korau-mp3:$korVersion"
|
||||
testCompile "com.soywiz:korge-tests:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-coffee'
|
||||
28
korge-sample1/build.gradle
Normal file
@@ -0,0 +1,28 @@
|
||||
dependencies {
|
||||
commonMainApi "com.soywiz:korge:$korgeVersion"
|
||||
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-android-aarch64"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-android-armv6"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-linux-amd64"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-linux-armv6"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-linux-armv6hf"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-linux-i586"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-macosx-universal"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-solaris-amd64"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-solaris-i586"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-windows-amd64"
|
||||
jvmMainApi "org.jogamp.gluegen:gluegen-rt:$gluegenVersion:natives-windows-i586"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-android-aarch64"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-android-armv6"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-amd64"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-armv6"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-armv6hf"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-i586"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-macosx-universal"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-solaris-amd64"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-solaris-i586"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-windows-amd64"
|
||||
jvmMainApi "org.jogamp.jogl:jogl-all:$joglVersion:natives-windows-i586"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.soywiz.korge.sample1
|
||||
|
||||
import com.soywiz.korge.Korge
|
||||
import com.soywiz.korge.view.solidRect
|
||||
import com.soywiz.korim.color.Colors
|
||||
|
||||
fun main(args: Array<String>) = Korge {
|
||||
solidRect(100, 100, Colors.RED)
|
||||
}
|
||||
6
korge-simon/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
@@ -1,46 +0,0 @@
|
||||
apply from: "../include.gradle"
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = "com.soywiz.korge.samples.simon.Simon"
|
||||
|
||||
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:korge-ext-ui:$korVersion"
|
||||
compile "com.soywiz:korau-mp3:$korVersion"
|
||||
|
||||
//nojtransc "com.soywiz:korge-ext-swf:$korVersion"
|
||||
//nojtransc "com.soywiz:korau-mp3:$korVersion"
|
||||
}
|
||||
|
||||
/*
|
||||
jtransc {
|
||||
//minimizeNames = true
|
||||
minimizeNames = false
|
||||
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
|
||||
6
korge-simon/common/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
@@ -1,12 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ 'src/main/resources', 'src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.soywiz:korge-common:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf-common:$korVersion"
|
||||
compile "com.soywiz:korge-ext-ui-common:$korVersion"
|
||||
compile "com.soywiz:korau-mp3-common:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-simon-common'
|
||||
@@ -1,135 +0,0 @@
|
||||
{
|
||||
"frames": {
|
||||
"0.png": {
|
||||
"frame": {
|
||||
"x": 2,
|
||||
"y": 2,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"rotated": false,
|
||||
"sourceSize": {
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"trimmed": false
|
||||
},
|
||||
"1.png": {
|
||||
"frame": {
|
||||
"x": 2,
|
||||
"y": 42,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"rotated": false,
|
||||
"sourceSize": {
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"trimmed": false
|
||||
},
|
||||
"2.png": {
|
||||
"frame": {
|
||||
"x": 2,
|
||||
"y": 82,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"rotated": false,
|
||||
"sourceSize": {
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"trimmed": false
|
||||
},
|
||||
"3.png": {
|
||||
"frame": {
|
||||
"x": 2,
|
||||
"y": 122,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"rotated": false,
|
||||
"sourceSize": {
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"trimmed": false
|
||||
},
|
||||
"4.png": {
|
||||
"frame": {
|
||||
"x": 2,
|
||||
"y": 162,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"rotated": false,
|
||||
"sourceSize": {
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"trimmed": false
|
||||
},
|
||||
"5.png": {
|
||||
"frame": {
|
||||
"x": 2,
|
||||
"y": 202,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"rotated": false,
|
||||
"sourceSize": {
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 32,
|
||||
"h": 40
|
||||
},
|
||||
"trimmed": false
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"app": "korge",
|
||||
"format": "RGBA8888",
|
||||
"image": "kotlin.atlas.png",
|
||||
"scale": 1.0,
|
||||
"size": {
|
||||
"w": 32,
|
||||
"h": 240
|
||||
},
|
||||
"version": "0.10.0"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"name":"kotlin.atlas","loaderVersion":0,"sha1":"f096d009db1e83bdd171bdd91f830bcb32e2be70","configSha1":""}
|
||||
|
Before Width: | Height: | Size: 664 B |
@@ -1,220 +0,0 @@
|
||||
package com.soywiz.korge.samples.simon
|
||||
|
||||
import com.soywiz.korge.Korge
|
||||
import com.soywiz.korge.atlas.Atlas
|
||||
import com.soywiz.korge.audio.SoundFile
|
||||
import com.soywiz.korge.audio.SoundSystem
|
||||
import com.soywiz.korge.audio.readSoundFile
|
||||
import com.soywiz.korge.input.mouse
|
||||
import com.soywiz.korge.plugin.KorgePlugin
|
||||
import com.soywiz.korge.resources.getPath
|
||||
import com.soywiz.korge.scene.Module
|
||||
import com.soywiz.korge.scene.ScaledScene
|
||||
import com.soywiz.korge.scene.Scene
|
||||
import com.soywiz.korge.scene.sleep
|
||||
import com.soywiz.korge.time.seconds
|
||||
import com.soywiz.korge.ui.UIFactory
|
||||
import com.soywiz.korge.ui.UIPlugin
|
||||
import com.soywiz.korge.ui.korui.koruiFrame
|
||||
import com.soywiz.korge.util.AutoClose
|
||||
import com.soywiz.korge.view.Container
|
||||
import com.soywiz.korge.view.Image
|
||||
import com.soywiz.korge.view.image
|
||||
import com.soywiz.korim.color.Colors
|
||||
import com.soywiz.korio.async.Signal
|
||||
import com.soywiz.korio.async.go
|
||||
import com.soywiz.korio.async.waitOne
|
||||
import com.soywiz.korio.inject.AsyncInjector
|
||||
import com.soywiz.korio.inject.InjectorAsyncDependency
|
||||
import com.soywiz.korio.lang.JvmStatic
|
||||
import com.soywiz.korma.geom.ISize
|
||||
import com.soywiz.korma.geom.SizeInt
|
||||
import com.soywiz.korma.random.MtRand
|
||||
import com.soywiz.korma.random.get
|
||||
import com.soywiz.korui.geom.len.Padding
|
||||
import com.soywiz.korui.geom.len.em
|
||||
import com.soywiz.korui.style.padding
|
||||
import com.soywiz.korui.ui.button
|
||||
import com.soywiz.korui.ui.click
|
||||
import com.soywiz.korui.ui.horizontal
|
||||
|
||||
object Simon : Module() {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) = Korge(this, injector = AsyncInjector()
|
||||
.mapPrototype { SelectLevelScene() }
|
||||
.mapPrototype { IngameScene() }
|
||||
)
|
||||
|
||||
override val size = SizeInt(1280, 720)
|
||||
override val windowSize = size * 0.75
|
||||
override val title = "Kotlin Simon"
|
||||
override val icon = "kotlin/0.png"
|
||||
override val mainScene = SelectLevelScene::class
|
||||
|
||||
override val plugins: List<KorgePlugin> = super.plugins + listOf(UIPlugin)
|
||||
|
||||
class Sequence(
|
||||
val max: Int,
|
||||
val random: MtRand = MtRand()
|
||||
) {
|
||||
val items = ArrayList<Int>()
|
||||
|
||||
fun ensure(num: Int): List<Int> {
|
||||
while (items.size < num) items.add(random[0, max])
|
||||
return items
|
||||
}
|
||||
}
|
||||
|
||||
enum class Difficulty(val items: Int) {
|
||||
EASY(3), MEDIUM(4), HARD(6)
|
||||
}
|
||||
|
||||
class SelectLevelScene : Scene(), InjectorAsyncDependency {
|
||||
lateinit var atlas: Atlas; private set
|
||||
lateinit var ui: UIFactory; private set
|
||||
|
||||
override suspend fun init(injector: AsyncInjector) {
|
||||
super.init(injector)
|
||||
|
||||
atlas = injector.getPath(Atlas::class, "kotlin.atlas")
|
||||
ui = injector.get(UIFactory::class)
|
||||
}
|
||||
|
||||
suspend override fun sceneInit(sceneView: Container) {
|
||||
// BUG: Kotlin-JS
|
||||
|
||||
sceneView += ui.koruiFrame {
|
||||
horizontal {
|
||||
padding = Padding(0.2.em)
|
||||
button("EASY").click { sceneContainer.pushTo<IngameScene>(Difficulty.EASY) }
|
||||
button("MEDIUM").click { sceneContainer.pushTo<IngameScene>(Difficulty.MEDIUM) }
|
||||
button("HARD").click { sceneContainer.pushTo<IngameScene>(Difficulty.HARD) }
|
||||
}
|
||||
}
|
||||
|
||||
//sceneView += ui.koruiFrame {
|
||||
// add(com.soywiz.korui.ui.Container(this.app, HorizontalLayout(app)).apply {
|
||||
// padding = Padding(0.2.em)
|
||||
// button("EASY").click { sceneContainer.pushTo<IngameScene>(Difficulty.EASY) }
|
||||
// button("MEDIUM").click { sceneContainer.pushTo<IngameScene>(Difficulty.MEDIUM) }
|
||||
// button("HARD").click { sceneContainer.pushTo<IngameScene>(Difficulty.HARD) }
|
||||
// })
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
class IngameScene : ScaledScene() {
|
||||
private lateinit var atlas: Atlas
|
||||
private lateinit var successSound: SoundFile
|
||||
private lateinit var failSound: SoundFile
|
||||
private lateinit var difficulty: Difficulty
|
||||
private lateinit var soundSystem: SoundSystem
|
||||
|
||||
override val sceneSize = ISize(128, 72)
|
||||
override val sceneScale: Double = 10.0
|
||||
|
||||
val sequence by lazy { Sequence(difficulty.items) }
|
||||
val images = arrayListOf<Image>()
|
||||
lateinit var sounds: List<SoundFile>
|
||||
|
||||
override suspend fun init(injector: AsyncInjector) {
|
||||
super.init(injector)
|
||||
atlas = injector.getPath(Atlas::class, "kotlin.atlas")
|
||||
successSound = injector.getPath(SoundFile::class, "sounds/success.wav")
|
||||
failSound = injector.getPath(SoundFile::class, "sounds/fail.mp3")
|
||||
difficulty = injector.getOrNull(Difficulty::class) ?: Difficulty.MEDIUM
|
||||
soundSystem = injector.get(SoundSystem::class)
|
||||
println("IngameScene.difficulty: $difficulty")
|
||||
}
|
||||
|
||||
suspend override fun sceneInit(sceneView: Container) {
|
||||
sounds = (0..8).map { resourcesRoot["sounds/$it.mp3"].readSoundFile(soundSystem) }
|
||||
|
||||
//val sv = views.scaleView(128, 72, 10.0)
|
||||
//sv += views.solidRect(72, 72, Colors.RED).apply { y = 10.0 }
|
||||
for (n in 0 until difficulty.items) {
|
||||
val image = views.image(atlas["$n.png"].texture).apply {
|
||||
//anchorX = 0.5
|
||||
anchorY = 0.5
|
||||
val w = (difficulty.items) * 20
|
||||
x = (128 / 2).toDouble() - (w / 2) + n * 20 - 4
|
||||
y = (72 / 2).toDouble()
|
||||
}
|
||||
images += image
|
||||
sceneView += image
|
||||
}
|
||||
//sceneView += sv
|
||||
|
||||
go {
|
||||
sleep(1.seconds)
|
||||
ingame()
|
||||
sceneContainer.back()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun ingame() {
|
||||
var turn = 1
|
||||
while (true) {
|
||||
cpuTurn(turn)
|
||||
if (!playerTurn(turn)) {
|
||||
println("FAILED!")
|
||||
val sound = failSound.play()
|
||||
//sound.await()
|
||||
sleep(0.5.seconds)
|
||||
break
|
||||
} else {
|
||||
println("SUCCESS START")
|
||||
val sound = successSound.play()
|
||||
//sound.await()
|
||||
sleep(0.5.seconds)
|
||||
println("SUCCESS END")
|
||||
}
|
||||
turn++
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun cpuTurn(turn: Int) {
|
||||
val seq = sequence.ensure(turn)
|
||||
for (item in seq) {
|
||||
highlight(item)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun playerTurn(turn: Int): Boolean {
|
||||
val seq = sequence.ensure(turn)
|
||||
for (pos in 0 until seq.size) {
|
||||
val item = readOne()
|
||||
if (seq[pos] != item) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private suspend fun readOne(): Int {
|
||||
return AutoClose { toclose ->
|
||||
val signal = Signal<Int>()
|
||||
for ((index, image) in images.withIndex()) {
|
||||
toclose += image.mouse.onUp {
|
||||
toclose.cancel()
|
||||
signal(index)
|
||||
go {
|
||||
highlight(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
signal.waitOne()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun highlight(index: Int) {
|
||||
println("PLAY START")
|
||||
val sound = soundSystem.play(sounds[index])
|
||||
println("PLAY PROGRESS")
|
||||
images[index].colorMul = Colors["#ff7f7f"]
|
||||
sleep(0.3.seconds)
|
||||
images[index].colorMul = Colors.WHITE
|
||||
//sound.await()
|
||||
sleep(0.5.seconds)
|
||||
println("PLAY END")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
requirejs(['output'], function (app) {
|
||||
window.app = app;
|
||||
app.com.soywiz.korge.samples.simon.Simon.main_kand9s$([]);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script src="program.js" type="text/javascript"></script>
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 2.9 KiB |
@@ -1 +0,0 @@
|
||||
kotlin
|
||||
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 12 KiB |
7
korge-simon/js/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
/web
|
||||
@@ -1,14 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(":korge-simon:common")
|
||||
|
||||
compile "com.soywiz:korge-js:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf-js:$korVersion"
|
||||
compile "com.soywiz:korge-ext-ui-js:$korVersion"
|
||||
compile "com.soywiz:korau-mp3-js:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-simon'
|
||||
6
korge-simon/jvm/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
@@ -1,17 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = 'com.soywiz.korge.samples.simon.Simon'
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(":korge-simon:common")
|
||||
|
||||
compile "com.soywiz:korge:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf:$korVersion"
|
||||
compile "com.soywiz:korge-ext-ui:$korVersion"
|
||||
compile "com.soywiz:korau-mp3:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-simon'
|
||||
7
korge-tic-tac-toe/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
/web
|
||||
7
korge-tic-tac-toe/common/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
/web
|
||||
@@ -1,100 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
//apply plugin: 'application'
|
||||
|
||||
//mainClassName = "com.soywiz.korge.tictactoe.TicTacToe"
|
||||
|
||||
sourceSets {
|
||||
//generated.resources.srcDirs = ['src/generated/resources']
|
||||
//main.resources.srcDirs = [ 'src/main/resources' ]
|
||||
main.resources.srcDirs = [ 'src/main/resources', 'src/generated/resources' ]
|
||||
}
|
||||
|
||||
/*
|
||||
sourceSets {
|
||||
generated.resources.srcDirs = [ 'genresources' ]
|
||||
|
||||
main.kotlin.srcDirs = [ 'src' ]
|
||||
main.resources.srcDirs = [ 'resources', 'genresources' ]
|
||||
test.kotlin.srcDirs = [ 'test' ]
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
dependencies {
|
||||
compile "com.soywiz:korge-common:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf-common:$korVersion"
|
||||
compile "com.soywiz:korau-mp3-common:$korVersion"
|
||||
testCompile "com.soywiz:korge-tests-common:$korVersion"
|
||||
//compile "com.soywiz:korge:$korVersion"
|
||||
//compile "com.soywiz:korge-ext-swf:$korVersion"
|
||||
//compile "com.soywiz:korau-mp3:$korVersion"
|
||||
}
|
||||
|
||||
/*
|
||||
compileKotlin2Js {
|
||||
kotlinOptions.outputFile = "${projectDir}/web/output.js"
|
||||
//kotlinOptions.moduleKind = "amd"
|
||||
kotlinOptions.moduleKind = "umd"
|
||||
//kotlinOptions.moduleKind = "commonjs"
|
||||
//kotlinOptions.sourceMap = true
|
||||
kotlinOptions.sourceMap = false
|
||||
}
|
||||
|
||||
|
||||
clean {
|
||||
delete new File("${projectDir}/web")
|
||||
}
|
||||
|
||||
compileKotlin2Js.doLast {
|
||||
configurations.compile.each { File file ->
|
||||
copy {
|
||||
includeEmptyDirs = false
|
||||
|
||||
from zipTree(file.absolutePath)
|
||||
into "${projectDir}/web"
|
||||
include { fileTreeElement ->
|
||||
def path = fileTreeElement.path
|
||||
(path.endsWith(".js") || path.endsWith(".js.map")) && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copy {
|
||||
from sourceSets.main.resources.srcDirs
|
||||
into "${projectDir}/web"
|
||||
}
|
||||
}
|
||||
|
||||
jar.enabled = false
|
||||
*/
|
||||
//distTar.enabled = false
|
||||
//distZip.enabled = false
|
||||
|
||||
|
||||
/*
|
||||
apply from: "../include.gradle"
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = "com.soywiz.korge.tictactoe.TicTacToe"
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
jar.enabled = false
|
||||
distTar.enabled = false
|
||||
distZip.enabled = false
|
||||
*/
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-tic-tac-toe-common'
|
||||
|
Before Width: | Height: | Size: 46 KiB |
@@ -1 +0,0 @@
|
||||
{"name":"main.swf","loaderVersion":16,"sha1":"516c0fac4fbcac08b7740d2cabcc718d08c6fab4","configSha1":"3c38f2d222663a800a900cf37498c8ff3b43e9fb"}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.soywiz.korge.tictactoe
|
||||
|
||||
import com.soywiz.korio.util.Extra
|
||||
import com.soywiz.korma.ds.Array2
|
||||
import com.soywiz.korma.geom.PointInt
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
enum class Chip { EMPTY, CROSS, CIRCLE }
|
||||
|
||||
class Board(val width: Int = 3, val height: Int = width, val lineSize: Int = width) {
|
||||
class Cell(val x: Int, val y: Int) : Extra by Extra.Mixin() {
|
||||
val pos = PointInt(x, y)
|
||||
var value = Chip.EMPTY
|
||||
}
|
||||
|
||||
val cells = Array2(width, height) { Cell(it % width, it / width) }
|
||||
|
||||
fun inside(x: Int, y: Int) = cells.inside(x, y)
|
||||
|
||||
fun select(x: Int, y: Int, dx: Int, dy: Int, size: Int): List<Cell>? {
|
||||
if (!inside(x, y)) return null
|
||||
if (!inside(x + dx * (size - 1), y + dy * (size - 1))) return null
|
||||
return (0 until size).map { cells[x + dx * it, y + dy * it] }
|
||||
}
|
||||
|
||||
val lines = kotlin.collections.ArrayList<List<Cell>>()
|
||||
|
||||
init {
|
||||
fun addLine(line: List<Cell>?) {
|
||||
if (line != null) lines += line
|
||||
}
|
||||
for (y in 0..height) {
|
||||
for (x in 0..width) {
|
||||
addLine(select(x, y, 1, 0, lineSize))
|
||||
addLine(select(x, y, 0, 1, lineSize))
|
||||
addLine(select(x, y, 1, 1, lineSize))
|
||||
addLine(select(width - x - 1, y, -1, 1, lineSize))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(x: Int, y: Int) = cells[x, y]
|
||||
operator fun set(x: Int, y: Int, value: Chip) = run { cells[x, y].value = value }
|
||||
|
||||
val Iterable<Cell>.chipLine: Chip?
|
||||
get() {
|
||||
val expected = this.first().value
|
||||
return if (expected == Chip.EMPTY) null else if (this.all { it.value == expected }) expected else null
|
||||
}
|
||||
|
||||
val moreMovements: Boolean get() = cells.any { it.value == Chip.EMPTY }
|
||||
|
||||
val winnerLine: List<Cell>?
|
||||
get() {
|
||||
val out = kotlin.collections.ArrayList<Cell>()
|
||||
for (line in lines) if (line.chipLine != null) out += line
|
||||
return if (out.isEmpty()) null else out.toSet().toList()
|
||||
}
|
||||
|
||||
val winner: Chip?
|
||||
get() {
|
||||
return winnerLine?.firstOrNull()?.value
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.soywiz.korge.tictactoe
|
||||
|
||||
import com.soywiz.korge.animate.play
|
||||
import com.soywiz.korge.input.onClick
|
||||
import com.soywiz.korge.input.onUp
|
||||
import com.soywiz.korge.time.milliseconds
|
||||
import com.soywiz.korge.tween.*
|
||||
import com.soywiz.korge.view.View
|
||||
import com.soywiz.korge.view.get
|
||||
import com.soywiz.korio.async.Signal
|
||||
import com.soywiz.korio.async.async
|
||||
import com.soywiz.korio.util.Extra
|
||||
|
||||
var Board.Cell.view by Extra.Property<View?> { null }
|
||||
val Board.Cell.vview: View get() = this.view!!
|
||||
val Board.Cell.onPress by Extra.Property { Signal<Unit>() }
|
||||
|
||||
fun Board.Cell.set(type: Chip) {
|
||||
this.value = type
|
||||
view["chip"].play(when (type) {
|
||||
Chip.EMPTY -> "empty"
|
||||
Chip.CIRCLE -> "circle"
|
||||
Chip.CROSS -> "cross"
|
||||
})
|
||||
}
|
||||
|
||||
suspend fun Board.Cell.setAnimate(type: Chip) {
|
||||
set(type)
|
||||
async {
|
||||
view.tween(
|
||||
(view["chip"]!!::alpha[0.7, 1.0]).linear(),
|
||||
(view["chip"]!!::scale[0.8, 1.0]).easeOutElastic(),
|
||||
time = 300.milliseconds
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var Board.Cell.highlighting by Extra.Property { false }
|
||||
|
||||
suspend fun Board.Cell.highlight(highlight: Boolean) {
|
||||
view["highlight"].play(if (highlight) "highlight" else "none")
|
||||
this.highlighting = highlight
|
||||
if (highlight) {
|
||||
async {
|
||||
|
||||
val hl = view["highlight"]!!
|
||||
while (highlighting) {
|
||||
hl.tween((hl::alpha[0.7]).easeInOutQuad(), time = 300.milliseconds)
|
||||
hl.tween((hl::alpha[1.0]).easeInOutQuad(), time = 200.milliseconds)
|
||||
}
|
||||
}
|
||||
|
||||
async {
|
||||
val ch = view["chip"]!!
|
||||
ch.tween((ch::scale[0.4]).easeOutQuad(), time = 100.milliseconds)
|
||||
ch.tween((ch::scale[1.2]).easeOutElastic(), time = 300.milliseconds)
|
||||
while (highlighting) {
|
||||
ch.tween((ch::scale[1.0]).easeOutQuad(), time = 300.milliseconds)
|
||||
ch.tween((ch::scale[1.2]).easeOutElastic(), time = 300.milliseconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun Board.Cell.lowlight(lowlight: Boolean) {
|
||||
async {
|
||||
view.tween(
|
||||
view!!::scale[1.0, 0.7],
|
||||
view!!::alpha[0.3],
|
||||
time = 300.milliseconds, easing = Easings.EASE_OUT_QUAD
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun Board.reset() {
|
||||
for (cell in cells) {
|
||||
//cell.view?.removeAllComponents()
|
||||
cell.set(Chip.EMPTY)
|
||||
cell.highlight(false)
|
||||
cell.view?.scale = 1.0
|
||||
cell.view?.alpha = 1.0
|
||||
cell.view["chip"]?.scale = 1.0
|
||||
cell.view["chip"]?.alpha = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
fun Board.Cell.init(view: View) {
|
||||
this.view = view
|
||||
set(this.value)
|
||||
view["hit"].onUp {
|
||||
onPress(Unit)
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.soywiz.korge.tictactoe
|
||||
|
||||
import com.soywiz.korge.animate.AnLibrary
|
||||
import com.soywiz.korge.resources.getPath
|
||||
import com.soywiz.korio.inject.AsyncInjector
|
||||
|
||||
// AUTOGENERATED:
|
||||
fun AsyncInjector.generatedInject() = this
|
||||
//.mapPrototype { TicTacToeMainScene(getPath("main.ani")) } // @TODO: kotlin.js bug
|
||||
//.mapPrototype { TicTacToeMainScene(getPath(AnLibrary::class, "main.ani")) }
|
||||
.mapPrototype { TicTacToeMainScene() }
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.soywiz.korge.tictactoe
|
||||
|
||||
import com.soywiz.korge.Korge
|
||||
import com.soywiz.korge.animate.AnLibrary
|
||||
import com.soywiz.korge.animate.AnLibraryPlugin
|
||||
import com.soywiz.korge.input.mouse
|
||||
import com.soywiz.korge.plugin.KorgePlugin
|
||||
import com.soywiz.korge.resources.getPath
|
||||
import com.soywiz.korge.scene.Module
|
||||
import com.soywiz.korge.scene.Scene
|
||||
import com.soywiz.korge.view.Container
|
||||
import com.soywiz.korge.view.descendantsWithPropInt
|
||||
import com.soywiz.korge.view.get
|
||||
import com.soywiz.korge.view.setText
|
||||
import com.soywiz.korio.async.Signal
|
||||
import com.soywiz.korio.async.go
|
||||
import com.soywiz.korio.async.waitOne
|
||||
import com.soywiz.korio.error.invalidOp
|
||||
import com.soywiz.korio.inject.AsyncInjector
|
||||
import com.soywiz.korio.lang.JvmStatic
|
||||
import com.soywiz.korma.geom.PointInt
|
||||
|
||||
object TicTacToe {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) = Korge(TicTacToeModule, injector = AsyncInjector().generatedInject())
|
||||
}
|
||||
|
||||
object TicTacToeModule : Module() {
|
||||
override val mainScene = TicTacToeMainScene::class
|
||||
override val title: String = "tic-tac-toe"
|
||||
override val icon: String = "icon.png"
|
||||
override val plugins: List<KorgePlugin> = super.plugins + listOf(
|
||||
AnLibraryPlugin
|
||||
)
|
||||
|
||||
suspend override fun init(injector: AsyncInjector) {
|
||||
//injector.get<ResourcesRoot>().mapExtensions("swf" to "ani")
|
||||
//injector.get<ResourcesRoot>().mapExtensionsJustInJTransc("swf" to "ani")
|
||||
}
|
||||
}
|
||||
|
||||
// Controller
|
||||
class TicTacToeMainScene : Scene() {
|
||||
private lateinit var mainLibrary: AnLibrary
|
||||
|
||||
val board = Board(3, 3)
|
||||
lateinit var game: Game
|
||||
|
||||
override suspend fun init(injector: AsyncInjector) {
|
||||
super.init(injector)
|
||||
|
||||
mainLibrary = injector.getPath(AnLibrary::class, "main.ani")
|
||||
}
|
||||
|
||||
suspend override fun sceneInit(sceneView: Container) {
|
||||
sceneView += mainLibrary.createMainTimeLine()
|
||||
|
||||
for ((rowView, row) in sceneView.descendantsWithPropInt("row")) {
|
||||
for ((cellView, cell) in rowView.descendantsWithPropInt("cell")) {
|
||||
board.cells[row, cell].init(cellView)
|
||||
}
|
||||
}
|
||||
|
||||
val p1 = InteractivePlayer(board, Chip.CROSS)
|
||||
val p2 = BotPlayer(board, Chip.CIRCLE)
|
||||
//val p2 = InteractivePlayer(board, Chip.CIRCLE)
|
||||
|
||||
game = Game(board, listOf(p1, p2))
|
||||
cancellables += go {
|
||||
while (true) {
|
||||
game.board.reset()
|
||||
val result = game.game()
|
||||
|
||||
println(result)
|
||||
|
||||
val results = mainLibrary.createMovieClip("Results")
|
||||
//(results["result"] as AnTextField).format?.face = Html.FontFace.Bitmap(font)
|
||||
when (result) {
|
||||
is Game.Result.DRAW -> results["result"].setText("DRAW")
|
||||
is Game.Result.WIN -> {
|
||||
results["result"].setText("WIN")
|
||||
for (cell in result.cells) cell.highlight(true)
|
||||
for (cell in game.board.cells.toList() - result.cells) cell.lowlight(true)
|
||||
}
|
||||
}
|
||||
sceneView += results
|
||||
results["hit"]?.mouse?.onClick?.waitOne()
|
||||
//sceneView -= results
|
||||
results.removeFromParent()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Player {
|
||||
val chip: Chip
|
||||
suspend fun move(): PointInt
|
||||
}
|
||||
|
||||
class Game(val board: Board, val players: List<Player>) {
|
||||
interface Result {
|
||||
object DRAW : Result
|
||||
class WIN(val player: Player?, val cells: List<Board.Cell>) : Result
|
||||
}
|
||||
|
||||
suspend fun game(): Result {
|
||||
var turn = 0
|
||||
while (board.moreMovements) {
|
||||
val currentPlayer = players[turn % players.size]
|
||||
while (true) {
|
||||
val pos = currentPlayer.move()
|
||||
println(pos)
|
||||
if (board.cells[pos].value == Chip.EMPTY) {
|
||||
board.cells[pos].setAnimate(currentPlayer.chip)
|
||||
break
|
||||
}
|
||||
}
|
||||
if (board.winner != null) return Result.WIN(currentPlayer, board.winnerLine ?: listOf())
|
||||
turn++
|
||||
}
|
||||
return Result.DRAW
|
||||
}
|
||||
}
|
||||
|
||||
class BotPlayer(val board: Board, override val chip: Chip) : Player {
|
||||
suspend override fun move(): PointInt {
|
||||
for (cell in board.cells) {
|
||||
if (cell.value == Chip.EMPTY) {
|
||||
return cell.pos
|
||||
}
|
||||
}
|
||||
invalidOp("No more movements")
|
||||
}
|
||||
}
|
||||
|
||||
class InteractivePlayer(val board: Board, override val chip: Chip) : Player {
|
||||
val clicked = Signal<PointInt>()
|
||||
|
||||
init {
|
||||
for (cell in board.cells) {
|
||||
cell.onPress {
|
||||
clicked(cell.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend override fun move(): PointInt {
|
||||
return clicked.waitOne()
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -1,21 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
requirejs(['output'], function (app) {
|
||||
window.app = app;
|
||||
app.com.soywiz.korge.tictactoe.TicTacToe.main_kand9s$([]);
|
||||
//app.com.soywiz.korio.example.MainJs.main()
|
||||
//app.Sample.main_kand9s$([]);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script src="program.js" type="text/javascript"></script>
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,9 +0,0 @@
|
||||
mipmaps: true
|
||||
antialiasing: true
|
||||
rasterizerMethod: X4
|
||||
exportScale: 2.0
|
||||
minShapeSide: 64
|
||||
maxShapeSide: 512
|
||||
minMorphShapeSide: 16
|
||||
maxMorphShapeSide: 128
|
||||
exportPaths: false
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.soywiz.korge.tictactoe
|
||||
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class BoardTest {
|
||||
@Test
|
||||
fun name() {
|
||||
val board = Board()
|
||||
assertEquals(null, board.winner)
|
||||
board[0, 0] = Chip.CROSS
|
||||
board[1, 0] = Chip.CROSS
|
||||
assertEquals(null, board.winner)
|
||||
board[2, 0] = Chip.CROSS
|
||||
assertEquals(Chip.CROSS, board.winner)
|
||||
}
|
||||
}
|
||||
7
korge-tic-tac-toe/js/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
/web
|
||||
@@ -1,14 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(":korge-tic-tac-toe:common")
|
||||
|
||||
compile "com.soywiz:korge-js:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf-js:$korVersion"
|
||||
compile "com.soywiz:korau-mp3-js:$korVersion"
|
||||
testCompile "com.soywiz:korge-tests-js:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-tic-tac-toe-js'
|
||||
7
korge-tic-tac-toe/jvm/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.gradle
|
||||
/build
|
||||
/classes
|
||||
/out
|
||||
/genresources
|
||||
/web
|
||||
@@ -1,18 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = 'com.soywiz.korge.tictactoe.TicTacToe'
|
||||
|
||||
sourceSets {
|
||||
main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(":korge-tic-tac-toe:common")
|
||||
|
||||
compile "com.soywiz:korge:$korVersion"
|
||||
compile "com.soywiz:korge-ext-swf:$korVersion"
|
||||
compile "com.soywiz:korau-mp3:$korVersion"
|
||||
testCompile "com.soywiz:korge-tests:$korVersion"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'korge-tic-tac-toe'
|
||||
@@ -1,16 +1,23 @@
|
||||
pluginManagement {
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "kotlin-multiplatform") {
|
||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' }
|
||||
maven { url 'https://plugins.gradle.org/m2/' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'korge-samples'
|
||||
|
||||
include(
|
||||
'korge-tic-tac-toe:common',
|
||||
'korge-tic-tac-toe:js',
|
||||
'korge-tic-tac-toe:jvm',
|
||||
|
||||
'korge-simon:common',
|
||||
'korge-simon:js',
|
||||
'korge-simon:jvm',
|
||||
|
||||
'korge-coffee:common',
|
||||
'korge-coffee:js',
|
||||
'korge-coffee:jvm',
|
||||
)
|
||||
enableFeaturePreview('GRADLE_METADATA')
|
||||
|
||||
include ':korge-sample1'
|
||||
|
||||
45
travis_win.bat
Normal file
@@ -0,0 +1,45 @@
|
||||
REM free some space
|
||||
|
||||
dir
|
||||
|
||||
REM dir c:\
|
||||
REM dir "c:\Program Files"
|
||||
REM dir "c:\Program Files (x86)"
|
||||
|
||||
REM dir /s C:\ProgramData\chocolatey
|
||||
REM choco uninstall all
|
||||
REM choco uninstall -y -f cmake cmake.install DotNet4.5 DotNet4.6 windows-sdk-10.0 winscp winscp.install ruby microsoft-build-tools visualstudio2017-workload-netcorebuildtools visualstudio2017-workload-vctools visualstudio2017-workload-webbuildtools visualstudio2017buildtools
|
||||
|
||||
RD /s /q "c:\Program Files\IIS"
|
||||
RD /s /q "c:\Program Files\Java"
|
||||
RD /s /q "c:\Program Files\Microsoft"
|
||||
RD /s /q "c:\Program Files\Microsoft Visual Studio"
|
||||
RD /s /q "c:\Program Files\Microsoft Visual Studio 14.0"
|
||||
RD /s /q "c:\Program Files\cmake"
|
||||
RD /s /q "c:\Program Files\Microsoft SDKs"
|
||||
RD /s /q "c:\Program Files (x86)\IIS"
|
||||
RD /s /q "c:\Program Files (x86)\Java"
|
||||
RD /s /q "c:\Program Files (x86)\Microsoft"
|
||||
RD /s /q "c:\Program Files (x86)\Microsoft Visual Studio"
|
||||
RD /s /q "c:\Program Files (x86)\Microsoft Visual Studio 14.0"
|
||||
RD /s /q "c:\Program Files (x86)\cmake"
|
||||
RD /s /q "c:\Program Files (x86)\Microsoft SDKs"
|
||||
REM RD /s /q C:\ProgramData\chocolatey
|
||||
REM RD /s /q C:\ProgramData
|
||||
|
||||
dir
|
||||
|
||||
choco list --local-only
|
||||
choco install jdk8 -y -params "installdir=c:\\java8"
|
||||
|
||||
del c:\java8\src.zip
|
||||
del c:\java8\javafx-src.zip
|
||||
|
||||
dir c:\java8
|
||||
dir c:\java8\lib
|
||||
|
||||
CALL refreshenv
|
||||
|
||||
SET JAVA_HOME=c:\java8
|
||||
CALL gradlew.bat --no-daemon -s -i mingwX64Test
|
||||
CALL gradlew.bat --stop
|
||||