mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
displays time on main window
This commit is contained in:
@@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||||
import com.sudoplay.joise.Joise
|
import com.sudoplay.joise.Joise
|
||||||
@@ -33,6 +34,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
|
|
||||||
private lateinit var batch: SpriteBatch
|
private lateinit var batch: SpriteBatch
|
||||||
private lateinit var camera: OrthographicCamera
|
private lateinit var camera: OrthographicCamera
|
||||||
|
private lateinit var font: BitmapFont
|
||||||
|
|
||||||
private lateinit var testTex: Pixmap
|
private lateinit var testTex: Pixmap
|
||||||
private lateinit var tempTex: Texture
|
private lateinit var tempTex: Texture
|
||||||
@@ -49,6 +51,8 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
private var generationStartTime = 0L
|
private var generationStartTime = 0L
|
||||||
|
|
||||||
override fun create() {
|
override fun create() {
|
||||||
|
font = BitmapFont() // use default because fuck it
|
||||||
|
|
||||||
batch = SpriteBatch()
|
batch = SpriteBatch()
|
||||||
camera = OrthographicCamera(WIDTH.toFloat(), HEIGHT.toFloat())
|
camera = OrthographicCamera(WIDTH.toFloat(), HEIGHT.toFloat())
|
||||||
camera.setToOrtho(false) // some elements are pre-flipped, while some are not. The statement itself is absolutely necessary to make edge of the screen as the origin
|
camera.setToOrtho(false) // some elements are pre-flipped, while some are not. The statement itself is absolutely necessary to make edge of the screen as the origin
|
||||||
@@ -63,6 +67,8 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
println("Init done")
|
println("Init done")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var generationTime = 0f
|
||||||
|
|
||||||
override fun render() {
|
override fun render() {
|
||||||
if (!generationDone) {
|
if (!generationDone) {
|
||||||
joise = getNoiseGenerator(seed)
|
joise = getNoiseGenerator(seed)
|
||||||
@@ -93,7 +99,17 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
if (ThreadParallel.allFinished() && generationTimeInMeasure) {
|
if (ThreadParallel.allFinished() && generationTimeInMeasure) {
|
||||||
generationTimeInMeasure = false
|
generationTimeInMeasure = false
|
||||||
val time = System.nanoTime() - generationStartTime
|
val time = System.nanoTime() - generationStartTime
|
||||||
println("Generation time in sec: ${time / 1000000000f}")
|
generationTime = time / 1000000000f
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw timer
|
||||||
|
batch.inUse {
|
||||||
|
if (!generationTimeInMeasure) {
|
||||||
|
font.draw(batch, "Generation time: ${generationTime} seconds", 8f, HEIGHT - 8f)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
font.draw(batch, "Generating...", 8f, HEIGHT - 8f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user