Skip to content

Instantly share code, notes, and snippets.

@marenovakovic
Last active December 29, 2025 12:53
Show Gist options
  • Select an option

  • Save marenovakovic/a3abd2f0ed26f3d3c7beee2bd03598ff to your computer and use it in GitHub Desktop.

Select an option

Save marenovakovic/a3abd2f0ed26f3d3c7beee2bd03598ff to your computer and use it in GitHub Desktop.
suspend fun main() = Korge(
windowSize = Size(640.0, 320.0),
backgroundColor = Colors.WHITE,
) {
val sceneContainer = sceneContainer()
sceneContainer.changeTo {
RpgScene()
}
}
private class RpgScene : Scene() {
override suspend fun SContainer.sceneMain() {
val idle = SpriteAnimation(
spriteMap = resourcesVfs["warrior/idle.png"].readBitmap(),
spriteWidth = 130,
spriteHeight = 145,
columns = 8,
rows = 1,
)
val attack = SpriteAnimation(
spriteMap = resourcesVfs["warrior/attack.png"].readBitmap(),
spriteWidth = 130,
spriteHeight = 145,
columns = 10,
rows = 1,
)
val death = SpriteAnimation(
spriteMap = resourcesVfs["warrior/death.png"].readBitmap(),
spriteWidth = 130,
spriteHeight = 145,
columns = 7,
rows = 1,
)
val character = sprite(idle)
character.playAnimationLooped(spriteDisplayTime = 200.milliseconds)
character.onAnimationCompleted({
character.playAnimationLooped(idle, spriteDisplayTime = 200.milliseconds)
})
uiHorizontalStack(padding = 4f) {
uiButton("Attack") {
onPress({ character.playAnimation(attack) })
}
uiButton("Death") {
onPress({ character.playAnimation(death) })
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment