Skip to content

Commit

Permalink
another fix for small font sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
heatherhaks authored Apr 2, 2019
1 parent 174c984 commit 5ca8a21
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/com/halfdeadgames/kterminal/KTerminalData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class KTerminalData(width: Int,

var terminal = Array(width) {
Array(height) {
KTerminalGlyph(' ', defaultForegroundColor, defaultBackgroundColor)
KTerminalGlyph(0, defaultForegroundColor, defaultBackgroundColor)
}
}

Expand All @@ -44,7 +44,7 @@ class KTerminalData(width: Int,

terminal = Array(width) {
Array(height) {
KTerminalGlyph(' ', defaultForegroundColor, defaultBackgroundColor)
KTerminalGlyph(0, defaultForegroundColor, defaultBackgroundColor)
}
}
}
Expand Down
35 changes: 21 additions & 14 deletions src/com/halfdeadgames/kterminal/KTerminalRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ class KTerminalRenderer(val batch: SpriteBatch,
}

private fun init(tilesetFile: String?, scale: Float = 1f) {
val tempTilesetFile = tilesetFile ?: "defaultKTerminalFontSheet.png"

if(tilesetFile == null) {
columns = 16
rows = 17
}

val tempTilesetFile = tilesetFile ?: "defaultKTerminalFontSheet.png"

println(tempTilesetFile)


val pixmap = Pixmap(Gdx.files.internal(tempTilesetFile))


Expand Down Expand Up @@ -174,19 +177,23 @@ class KTerminalRenderer(val batch: SpriteBatch,
val scaleX = if(glyph.isFlippedY) -glyph.scale else glyph.scale
val scaleY = if(glyph.isFlippedX) -glyph.scale else glyph.scale

if(glyph.isSubCellEnabled) {
val topLeft = glyph.subCellGlyph.topLeft
val topRight = glyph.subCellGlyph.topRight
val bottomLeft = glyph.subCellGlyph.bottomLeft
val bottomRight = glyph.subCellGlyph.bottomRight

draw(glyphs[topLeft.value], topLeft.color, glyph, i, j, scaleX, scaleY)
draw(glyphs[topRight.value], topRight.color, glyph, i, j, scaleX, scaleY)
draw(glyphs[bottomLeft.value], bottomLeft.color, glyph, i, j, scaleX, scaleY)
draw(glyphs[bottomRight.value], bottomRight.color, glyph, i, j, scaleX, scaleY)
if(glyph.value >= columns * rows) {
throw IllegalArgumentException("glyph value [${glyph.value}] exceeds found glyph count [${(columns * rows) - 1}]")
} else {
if(glyph.isSubCellEnabled) {
val topLeft = glyph.subCellGlyph.topLeft
val topRight = glyph.subCellGlyph.topRight
val bottomLeft = glyph.subCellGlyph.bottomLeft
val bottomRight = glyph.subCellGlyph.bottomRight

draw(glyphs[topLeft.value], topLeft.color, glyph, i, j, scaleX, scaleY)
draw(glyphs[topRight.value], topRight.color, glyph, i, j, scaleX, scaleY)
draw(glyphs[bottomLeft.value], bottomLeft.color, glyph, i, j, scaleX, scaleY)
draw(glyphs[bottomRight.value], bottomRight.color, glyph, i, j, scaleX, scaleY)
}

draw(glyphs[glyph.value], kTerminalData.terminal[i][j].foregroundColor, glyph, i, j, scaleX, scaleY)
}

draw(glyphs[glyph.value], kTerminalData.terminal[i][j].foregroundColor, glyph, i, j, scaleX, scaleY)
}
}

Expand Down

0 comments on commit 5ca8a21

Please sign in to comment.