Skip to content

Commit

Permalink
Add LDtkLevelView to Drawable family
Browse files Browse the repository at this point in the history
  • Loading branch information
jobe-m committed Feb 9, 2024
1 parent 15a3b09 commit 73b2791
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import korlibs.korge.fleks.entity.config.invalidEntity
import korlibs.korge.fleks.utils.SerializeBase
import korlibs.io.lang.format
import korlibs.io.lang.substr
import korlibs.util.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlin.math.roundToInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ data class TiledMap(
}

@Serializable
@SerialName("LdtkTileMap")
data class LdtkTileMap(
var assetName: String = "",
@SerialName("LdtkLevelMap")
data class LdtkLevelMap(
/**
* The name of the LDtk world in the Asset manager
*/
var worldName: String = "",
/**
* The unique identifier (level name) of the level from the LDtk world
*/
var levelName: String = ""

) : Component<LdtkTileMap>, SerializeBase {
override fun type(): ComponentType<LdtkTileMap> = LdtkTileMap
companion object : ComponentType<LdtkTileMap>()
) : Component<LdtkLevelMap>, SerializeBase {
override fun type(): ComponentType<LdtkLevelMap> = LdtkLevelMap
companion object : ComponentType<LdtkLevelMap>()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import korlibs.korge.fleks.entity.config.Invokable
import korlibs.korge.fleks.systems.KorgeViewSystem
import korlibs.korge.fleks.utils.KorgeViewCache
import korlibs.korge.input.mouse
import korlibs.korge.ldtk.view.*
import korlibs.korge.parallax.ImageDataViewEx
import korlibs.korge.parallax.ParallaxConfig
import korlibs.korge.parallax.ParallaxDataView
Expand Down Expand Up @@ -71,12 +72,20 @@ val onDrawableFamilyAdded: FamilyHook = { entity ->
//
// TiledMapView(assets.getTiledMap(entity[TiledMap].assetName), smoothing = false, showShapes = false)
// }
/*
entity has LdtkTileMap -> {
tileMap

entity has LdtkLevelMap -> {
val ldtkLevelMapComponent = entity[LdtkLevelMap]
val ldtkWorld = AssetStore.getLdtkWorld(ldtkLevelMapComponent.worldName)
val ldtkLevel = AssetStore.getLdtkLevel(ldtkWorld, ldtkLevelMapComponent.levelName)
val view = LDTKLevelView(level = LDTKLevel(
world = ldtkWorld,
level = ldtkLevel
))
width = ldtkLevel.pxWid.toFloat()
height = ldtkLevel.pxHei.toFloat()
view
}
*/

entity has Parallax -> {
val parallax = entity[Parallax]
val parallaxConfig = AssetStore.getBackground(parallax.config.name)
Expand Down

0 comments on commit 73b2791

Please sign in to comment.