Skip to content

Commit

Permalink
Update AssetStore and DialogBoxConfig (#38)
Browse files Browse the repository at this point in the history
- Add pivot point offset to position of entities from LTtk level map
- Add textWritingFactor to DialogBoxConfig to specify writing speed instead of hardcoding values
  • Loading branch information
jobe-m authored Jan 14, 2025
1 parent 617da48 commit 8117d16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,15 @@ class AssetStore {
yamlString.append("name: ${levelName}_${entity.identifier}_${gameObjectCnt++}\n")
}

// Add position of entity = grid position + pivot point
val entityPosX: Int = (entity.gridPos.x * gridSize) + (entity.pivot[0] * gridSize).toInt()
val entityPosY: Int = (entity.gridPos.y * gridSize) + (entity.pivot[1] * gridSize).toInt()


// Add position of entity
entity.tags.firstOrNull { it == "positionable" }?.let {
yamlString.append("x: ${entity.gridPos.x * gridSize}\n")
yamlString.append("y: ${entity.gridPos.y * gridSize}\n")
yamlString.append("x: $entityPosX\n")
yamlString.append("y: $entityPosY\n")
}

// Add all other fields of entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ data class DialogBoxConfig(
private val text: String,
private val textFontName: String,
private val textRangeEnd: Int = 0, // initial value for drawing the text into the dialog
private val textWritingFactor: Float = 0.035f,
@Serializable(with = HAlignAsString::class) private val textHAlign: HorizontalAlign = HorizontalAlign.LEFT,
@Serializable(with = VAlignAsString::class) private val textVAlign: VerticalAlign = VerticalAlign.TOP,
) : EntityConfig {
Expand Down Expand Up @@ -149,7 +150,7 @@ data class DialogBoxConfig(
TweenPosition(entity = avatar, x = avatarTweenX, duration = 0.5f, easing = Easing.EASE_OUT_QUAD),
TweenRgba(entity = textBox, alpha = 1f, delay = 0.3f, duration = 0.3f, easing = Easing.EASE_OUT_QUAD),
// Type write text into the dialog
TweenTextField(entity = textField, textRangeEnd = text.length, delay = 0.3f + 0.8f, duration = text.length * 0.07f)
TweenTextField(entity = textField, textRangeEnd = text.length, delay = 0.3f + 0.8f, duration = text.length * textWritingFactor)
)
),
Wait(duration = duration),
Expand Down

0 comments on commit 8117d16

Please sign in to comment.