Is it possible to use Korge in a Kotlin JS project...
# korge
m
Is it possible to use Korge in a Kotlin JS project?
👌 1
Is there any example i can look at? where is korge-js published?
m
There is a sample repo https://github.com/korlibs/korge-samples you can use runJs task for javascript
m
Thanks for the reply. Ill give you some background. I have this fullstack multiplatform project only meant to be a web-game (not using any other multiplatform features other than being server + web client). In this project i want to use Korge´s js parts use as the main game engine. Ideally i would like to include a dependency(korge-js?) and use that from my jsMain part of my project. Is this possible? When looking at the examples all seems to be using the Korge Gradle Plugin and that seems to include alot more than just the js part(i might be wrong).
m
AFAIK, you can create a jsJar or a webpack. And maybe you could even add korge dependency directly to the project as is done by the plugin https://github.com/korlibs/korge-plugins/blob/9b6c8c1a5a3520d6cd948451ab3a088951bf9f88/korge-gradle-plugin/src/main/kotlin/com/soywiz/korge/gradle/KorgeGradlePlugin.kt#L45 I don't have any experience with JS, so maybe @Deactivated User can help
m
Thanks for the help @Mayank Got it to work by just depending on:
Copy code
implementation("com.soywiz.korlibs.korge:korge-js:2.0.0-rc3")
and using this repo :
Copy code
maven { url = uri("<https://dl.bintray.com/korlibs/korlibs/>") }
👍 1
Is there anyway to control where the canvas gets added in the html tree? Or maybe point it to a canvas with a specific id? @Deactivated User
d
Sorry for the delay, I was on holidays and forgot to update my state. Relevant parts: • https://github.com/korlibs/korge-next/blob/2782e295990a5452b9629581f8611ab580c2dc76/korgw/src/jsMain/kotlin/com/soywiz/korag/GlExt.kt#L38https://github.com/korlibs/korge-next/blob/2782e295990a5452b9629581f8611ab580c2dc76/korgw/src/jsMain/kotlin/com/soywiz/kgl/KmlGlJsCanvas.kt#L23https://github.com/korlibs/korge-next/blob/2782e295990a5452b9629581f8611ab580c2dc7[…]korgw/src/jsMain/kotlin/com/soywiz/korgw/DefaultGameWindowJs.kthttps://github.com/korlibs/korge-next/blob/2782e295990a5452b9629581f8611ab580c2dc7[…]korgw/src/jsMain/kotlin/com/soywiz/korgw/DefaultGameWindowJs.kt Before 1.0, it didn't create the canvas if a canvas with the id "game" existed, but I think we removed that. We could reuse a canvas, either propagating it via the Korge block or just trying to get it by id. If the canvas exists we should not handle the resize ourselves. That would work for you?
m
that would be perfect! 👍
get it by id
d
configurable, or any id would work for you?
m
any id would work fine
d
for example
id="korge-game-canvas"
okay
m
yeah
d