mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
Various Loadscreens WIP
This commit is contained in:
@@ -169,6 +169,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
lateinit var theRealGamer: IngamePlayer
|
||||
// get() = actorGamer as IngamePlayer
|
||||
|
||||
|
||||
|
||||
enum class GameLoadMode {
|
||||
CREATE_NEW, LOAD_FROM
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package net.torvald.terrarum.modulebasegame
|
||||
import com.badlogic.gdx.ScreenAdapter
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.IngameInstance
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.util.CircularArray
|
||||
import kotlin.math.roundToInt
|
||||
@@ -14,10 +13,12 @@ import kotlin.math.roundToInt
|
||||
*
|
||||
* Created by minjaesong on 2019-11-09.
|
||||
*/
|
||||
class WorldgenLoadScreen(private var world: GameWorld, private var screenToLoad: IngameInstance) : ScreenAdapter() {
|
||||
class WorldgenLoadScreen(private val world: GameWorld, screenToBeLoaded: IngameInstance) : LoadScreenBase() {
|
||||
|
||||
// a Class impl is chosen to make resize-handling easier, there's not much benefit making this a singleton anyway
|
||||
|
||||
override var screenToLoad: IngameInstance? = screenToBeLoaded
|
||||
|
||||
companion object {
|
||||
private const val WIDTH_RATIO = 0.6
|
||||
}
|
||||
@@ -25,13 +26,9 @@ class WorldgenLoadScreen(private var world: GameWorld, private var screenToLoad:
|
||||
private val previewWidth = (AppLoader.screenW * WIDTH_RATIO).roundToInt()
|
||||
private val previewHeight = (AppLoader.screenW * WIDTH_RATIO * world.height / world.width).roundToInt()
|
||||
|
||||
private lateinit var screenLoadingThread: Thread
|
||||
|
||||
private lateinit var previewPixmap: Pixmap
|
||||
private lateinit var previewTexture: Texture
|
||||
|
||||
private val messages = CircularArray<String>(20, true) // this many texts will be shown at once
|
||||
|
||||
override fun show() {
|
||||
previewPixmap = Pixmap(previewWidth, previewHeight, Pixmap.Format.RGBA8888)
|
||||
previewTexture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||
@@ -42,6 +39,12 @@ class WorldgenLoadScreen(private var world: GameWorld, private var screenToLoad:
|
||||
previewTexture = Texture(previewPixmap)
|
||||
|
||||
//
|
||||
AppLoader.batch.inUse {
|
||||
it.draw(previewTexture,
|
||||
(AppLoader.screenW - previewWidth).div(2f).round(),
|
||||
(AppLoader.screenH - previewHeight.times(1.25f)).div(2f).round()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
@@ -2,7 +2,9 @@ package net.torvald.terrarum.modulebasegame.worldgenerator
|
||||
|
||||
import com.sudoplay.joise.Joise
|
||||
import com.sudoplay.joise.module.*
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.LoadScreen
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.concurrent.ThreadExecutor
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -28,7 +30,10 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
// single-threaded impl because I couldn't resolve multithread memory corruption issue...
|
||||
genFuture = ThreadExecutor.submit {
|
||||
for (x in 0 until world.width) {
|
||||
printdbg(this, "Tile draw for x=$x")
|
||||
|
||||
if (AppLoader.IS_DEVELOPMENT_BUILD)
|
||||
LoadScreen.addMessage("Tile draw for x=$x")
|
||||
|
||||
for (y in 0 until world.height) {
|
||||
val sampleTheta = (x.toDouble() / world.width) * TWO_PI
|
||||
val sampleOffset = world.width / 8.0
|
||||
|
||||
Reference in New Issue
Block a user