mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
Terrarum Sans Bitmap imple on GDX -- wip
This commit is contained in:
7
src/net/torvald/terrarum/TerrarumGDX.kt
Normal file
7
src/net/torvald/terrarum/TerrarumGDX.kt
Normal file
@@ -0,0 +1,7 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-06-15.
|
||||
*/
|
||||
object TerrarumGDX {
|
||||
}
|
||||
@@ -6,8 +6,9 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
||||
import com.badlogic.gdx.graphics.GL20
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,17 +19,26 @@ class TestTestTest : ApplicationAdapter() {
|
||||
lateinit var batch: SpriteBatch
|
||||
lateinit var img: Texture
|
||||
|
||||
lateinit var gameFont: BitmapFont
|
||||
|
||||
override fun create() {
|
||||
batch = SpriteBatch()
|
||||
img = Texture("assets/test_texture.tga")
|
||||
|
||||
gameFont = GameFontBase(false)
|
||||
//gameFont = BitmapFont()
|
||||
}
|
||||
|
||||
override fun render() {
|
||||
Gdx.gl.glClearColor(1f, 0f, 0f, 1f)
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
batch.begin()
|
||||
batch.draw(img, 0f, 0f)
|
||||
batch.end()
|
||||
|
||||
Gdx.graphics.setTitle("$GAME_NAME — F: ${Gdx.graphics.framesPerSecond}")
|
||||
|
||||
batch.inBatch {
|
||||
|
||||
gameFont.draw(batch, "Hello, world!", 10f, 30f)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
@@ -36,9 +46,18 @@ class TestTestTest : ApplicationAdapter() {
|
||||
img.dispose()
|
||||
}
|
||||
|
||||
|
||||
private inline fun SpriteBatch.inBatch(action: () -> Unit) {
|
||||
this.begin()
|
||||
action()
|
||||
this.end()
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) { // LWJGL 3 won't work? java.lang.VerifyError
|
||||
val config = LwjglApplicationConfiguration()
|
||||
config.useGL30 = true
|
||||
config.vSyncEnabled = false
|
||||
//config.foregroundFPS = 9999
|
||||
LwjglApplication(TestTestTest(), config)
|
||||
}
|
||||
Reference in New Issue
Block a user