LibGDX, here I am.

This commit is contained in:
minjaesong
2017-06-22 02:31:07 +09:00
parent 1ecbc57f83
commit ad481853bb
356 changed files with 3125 additions and 21138 deletions

View File

@@ -0,0 +1,78 @@
package net.torvald.terrarum.imagefont
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
* Created by SKYHi14 on 2017-03-24.
*/
class NewRunes : BitmapFont() {
private val runeSize = 12
// hard-coded encode map
private fun codeToEnc(code: Int): Int? = if (code in 0x21..0x3f)
code - 0x20
else if (code in 0x3001..0x300f)
code - 0x3000 + 0x20
else if (code in 0x3131..0x3163)
code - 0x3130 + 0x30
else
null
private val runes = TextureRegionPack("./assets/graphics/fonts/newrunes.tga", runeSize, runeSize)
var scale = 1
var linegap = 8
fun getWidth(str: String) = runeSize * str.length
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
str.forEachIndexed { index, c ->
val encodePoint = codeToEnc(c.toInt())
if (encodePoint != null) {
batch.draw(
runes.get(encodePoint % 16, encodePoint / 16),
x + runeSize * index * scale.toFloat(),
y * scale.toFloat()
)
}
}
return null
}
override fun usesIntegerPositions() = true
override fun ownsTexture() = true
override fun getXHeight() = runeSize.toFloat()
override fun getCapHeight() = runeSize.toFloat()
override fun getLineHeight() = (runeSize + linegap) * scale.toFloat()
}
/*
How runes are made:
The new runes are based on Hangul writing system. The runes had two main goals:
- Implement the principle of its design (specifically, how this letter is altered from its base shape)
- {KIYEOK, KHIEUKH}, {TIKEUT, THIEUTH, NIEUN}, {PIEUP, PHIEUPH, MIEUM}, {CIEUC, CHIEUCH, SIOS} sets
are similar in shape
- Aspirated sounds keep similar shape to their base
- Vowels are not random; they have rules
- In non-assembled writing, IEUNG only appears as "-ng" phoneme, so the shape is based on
old Hangul YESIEUNG, which actually had "-ng" sound
- "Doensori" are realised by prepending SIOS, much like older Korean orthography
- Good enough obfuscation
Notes:
- In some letters (e.g. NIEUN-HIEUH), ligatures may applied
- EU appear as non-assembled shape; U-shape instead of dash
*/

View File

@@ -0,0 +1,39 @@
package net.torvald.terrarum.imagefont
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
* Created by minjaesong on 16-04-15.
*/
object TinyAlphNum : BitmapFont() {
internal val W = 8
internal val H = 8
internal val fontSheet = TextureRegionPack("./assets/graphics/fonts/milky.tga", W, H)
init {
setOwnsTexture(true)
setUseIntegerPositions(true)
}
fun getWidth(str: String): Int {
return W * str.length
}
override fun draw(batch: Batch, text: CharSequence, x: Float, y: Float): GlyphLayout? {
text.forEachIndexed { index, c ->
batch.draw(fontSheet.get(index % 16, index / 16), x + index * W, y)
}
return null
}
override fun getLineHeight() = H.toFloat()
override fun getCapHeight() = getLineHeight()
override fun getXHeight() = getLineHeight()
}

View File

@@ -0,0 +1,43 @@
package net.torvald.terrarum.imagefont
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarum.ModMgr
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
* Created by minjaesong on 2017-06-21.
*/
object Watch7SegMain : BitmapFont() {
val charMapping = ('0'..'9')
internal val W = 11
internal val H = 18
internal val fontSheet = TextureRegionPack(ModMgr.getGdxFile("basegame", "fonts/7segnum.tga"), W, H)
init {
setOwnsTexture(true)
}
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
str.forEachIndexed { index, c ->
batch.draw(
if (c != ' ' && c in charMapping)
fontSheet.get(1 + (c - '0'), 0)
else
fontSheet.get(0, 0)
, x + W * index, y)
}
return null
}
override fun getLineHeight() = H.toFloat()
override fun getCapHeight() = getLineHeight()
override fun getXHeight() = getLineHeight()
}

View File

@@ -0,0 +1,42 @@
package net.torvald.terrarum.imagefont
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarum.ModMgr
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
* Created by minjaesong on 2017-06-21.
*/
object Watch7SegSmall : BitmapFont() {
val charMapping = (' '..'9')
internal val W = 9
internal val H = 12
internal val fontSheet = TextureRegionPack(ModMgr.getGdxFile("basegame", "fonts/7seg_small.tga"), W, H)
init {
setOwnsTexture(true)
}
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
str.forEachIndexed { index, c ->
if (c in charMapping) {
batch.draw(
fontSheet.get((c - ' ') % 16, (c - ' ') / 16),
x + W * index, y
)
}
}
return null
}
override fun getLineHeight() = H.toFloat()
override fun getCapHeight() = getLineHeight()
override fun getXHeight() = getLineHeight()
}

View File

@@ -0,0 +1,42 @@
package net.torvald.terrarum.imagefont
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.GlyphLayout
import net.torvald.terrarum.ModMgr
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
* Created by minjaesong on 2017-06-21.
*/
object WatchDotAlph : BitmapFont() {
val charMapping = ('A'..'Z')
internal val W = 12
internal val H = 10
internal val fontSheet = TextureRegionPack(ModMgr.getGdxFile("basegame", "fonts/watch_dotalph.tga"), W, H)
init {
setOwnsTexture(true)
}
override fun draw(batch: Batch, str: CharSequence, x: Float, y: Float): GlyphLayout? {
str.forEachIndexed { index, c ->
batch.draw(
if (c != ' ' && c in charMapping)
fontSheet.get(1 + (c - 'A'), 0)
else
fontSheet.get(0, 0)
, x + W * index, y)
}
return null
}
override fun getLineHeight() = H.toFloat()
override fun getCapHeight() = getLineHeight()
override fun getXHeight() = getLineHeight()
}