mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
clouds with just right depths
This commit is contained in:
@@ -32,4 +32,5 @@ Teleport
|
||||
ToggleNoClip
|
||||
Zoom
|
||||
DynToStatic
|
||||
DebugFillInventory
|
||||
DebugFillInventory
|
||||
Uuid
|
||||
|
@@ -2,17 +2,18 @@
|
||||
"skyboxGradColourMap": "generic_skybox.tga",
|
||||
"daylightClut": "clut_daylight.tga",
|
||||
"classification": "generic",
|
||||
"cloudChance": 10,
|
||||
"cloudGamma": [0.59, 2.0],
|
||||
"cloudDriftSpeed": 10.4,
|
||||
"cloudChance": 20,
|
||||
"cloudGamma": [0.48, 1.8],
|
||||
"cloudGammaVariance": [0.1, 0.1],
|
||||
"cloudDriftSpeed": 0.3,
|
||||
"clouds": {
|
||||
"large": {
|
||||
"filename": "cloud_large.png",
|
||||
"tw": 2048, "th": 1024, "probability": 0.2, "baseScale": 0.45, "scaleVariance": 0.7
|
||||
"tw": 2048, "th": 1024, "probability": 0.2, "baseScale": 0.666, "scaleVariance": 0.7
|
||||
},
|
||||
"normal": {
|
||||
"filename": "cloud_normal.png",
|
||||
"tw": 1024, "th": 512, "probability": 1.0, "baseScale": 0.5, "scaleVariance": 0.8
|
||||
"tw": 1024, "th": 512, "probability": 1.0, "baseScale": 0.75, "scaleVariance": 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -269,8 +269,8 @@ public class App implements ApplicationListener {
|
||||
Gdx.gl20.glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
public static final int TICKS = 64;
|
||||
public static final float UPDATE_RATE = 1f / TICKS; // apparent framerate will be limited by update rate
|
||||
public static final int TICK_SPEED = 64;
|
||||
public static final float UPDATE_RATE = 1f / TICK_SPEED; // apparent framerate will be limited by update rate
|
||||
|
||||
private static float loadTimer = 0f;
|
||||
private static final float showupTime = 100f / 1000f;
|
||||
|
||||
22
src/net/torvald/terrarum/modulebasegame/console/Uuid.kt
Normal file
22
src/net/torvald/terrarum/modulebasegame/console/Uuid.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.ccG
|
||||
import net.torvald.terrarum.ccY
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-08-22.
|
||||
*/
|
||||
object Uuid : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val worldUUID = INGAME.world.worldIndex
|
||||
val playerUUID = INGAME.actorGamer.uuid
|
||||
Echo("${ccY}World UUID: ${ccG}$worldUUID")
|
||||
Echo("${ccY}Player UUID: ${ccG}$playerUUID")
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ data class BaseModularWeather(
|
||||
val cloudChance: Float,
|
||||
val cloudDriftSpeed: Float,
|
||||
val cloudGamma: Vector2,
|
||||
val cloudGammaVariance: Vector2,
|
||||
var clouds: List<CloudProps>, // sorted by CloudProps.probability
|
||||
|
||||
val mixFrom: String? = null,
|
||||
|
||||
@@ -86,7 +86,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
private var astrumOffX = 0f
|
||||
private var astrumOffY = 0f
|
||||
|
||||
private val clouds = Array<WeatherObjectCloud?>(256) { null }
|
||||
private val clouds = Array<WeatherObjectCloud?>(4096) { null }
|
||||
private var cloudsSpawned = 0
|
||||
private var cloudDriftVector = Vector3(-1f, 0f, 1f) // this is a direction vector
|
||||
|
||||
@@ -94,6 +94,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
override fun loadFromSave(s0: Long, s1: Long) {
|
||||
super.loadFromSave(s0, s1)
|
||||
internalReset(s0, s1)
|
||||
initClouds()
|
||||
}
|
||||
|
||||
fun internalReset() = internalReset(RNG.state0, RNG.state1)
|
||||
@@ -155,6 +156,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
0f,
|
||||
0f,
|
||||
Vector2(1f, 1f),
|
||||
Vector2(0f, 0f),
|
||||
listOf()
|
||||
)
|
||||
|
||||
@@ -221,14 +223,14 @@ internal object WeatherMixer : RNGConsumer {
|
||||
private fun randomPosWithin(range: ClosedFloatingPointRange<Float>, random: Float) =
|
||||
((range.start + range.endInclusive) / 2f) + random * (range.endInclusive - range.start) / 2f
|
||||
|
||||
private fun tryToSpawnCloud(currentWeather: BaseModularWeather) {
|
||||
private fun tryToSpawnCloud(currentWeather: BaseModularWeather, initX: Float? = null) {
|
||||
printdbg(this, "Trying to spawn a cloud... (${cloudsSpawned} / ${clouds.size})")
|
||||
|
||||
if (cloudsSpawned < clouds.size) {
|
||||
val flip = Math.random() < 0.5
|
||||
val rC = Math.random().toFloat()
|
||||
val rZ = (Math.random() * 3.0 + 1.0).toFloat() // 1..4
|
||||
val r0 = (Math.random() * 2.0 - 1.0).toFloat() // -1..1
|
||||
val rZ = (Math.random() * 9 + 1.0).toFloat() // 1..10 uniformly
|
||||
val rY = ((Math.random() + Math.random()) - 1.0).toFloat() // -1..1
|
||||
val r1 = (Math.random() * 2.0 - 1.0).toFloat() // -1..1
|
||||
val r2 = (Math.random() * 2.0 - 1.0).toFloat() // -1..1
|
||||
val rT1 = ((Math.random() + Math.random()) - 1.0).toFloat() // -1..1
|
||||
@@ -249,11 +251,11 @@ internal object WeatherMixer : RNGConsumer {
|
||||
cloudsToSpawn?.let { cloud ->
|
||||
val scaleVariance = 1f + rT1.absoluteValue * cloud.scaleVariance
|
||||
val cloudScale = cloud.baseScale * (if (rT1 < 0) 1f / scaleVariance else scaleVariance)
|
||||
val hCloudSize = (cloud.spriteSheet.tileW * cloudScale) + 1f
|
||||
val posX = if (cloudDriftVector.x < 0) (App.scr.width + hCloudSize) * rZ else -hCloudSize * rZ
|
||||
val hCloudSize = (cloud.spriteSheet.tileW * cloudScale) / 2f + 1f
|
||||
val posX = if (initX != null) initX * rZ else if (cloudDriftVector.x < 0) (App.scr.width + hCloudSize) * rZ else -hCloudSize * rZ
|
||||
val posY = when (cloud.category) {
|
||||
"large" -> randomPosWithin(-10f..120f, r0) * scrHscaler
|
||||
else -> randomPosWithin(-50f..150f, r0) * scrHscaler // -50..150
|
||||
"large" -> randomPosWithin(-120f..120f, rY) * scrHscaler * (rZ * 0.5f)
|
||||
else -> randomPosWithin(-150f..150f, rY) * scrHscaler * (rZ * 0.5f)
|
||||
}
|
||||
val sheetX = rA % cloud.spriteSheet.horizontalCount
|
||||
val sheetY = rB % cloud.spriteSheet.verticalCount
|
||||
@@ -262,8 +264,12 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
it.darkness.set(currentWeather.cloudGamma)
|
||||
it.darkness.x *= it.scale
|
||||
it.darkness.x *= 1f + r1 * 0.1f
|
||||
it.darkness.y *= 1f + r2 * 0.1f
|
||||
|
||||
val varX = 1f + r1.absoluteValue * currentWeather.cloudGammaVariance.x
|
||||
val varY = 1f + r2.absoluteValue * currentWeather.cloudGammaVariance.y
|
||||
|
||||
it.darkness.x *= if (r1 < 0) 1f / varX else varX
|
||||
it.darkness.y *= if (r2 < 0) 1f / varY else varY
|
||||
|
||||
it.posX = posX
|
||||
it.posY = posY
|
||||
@@ -280,6 +286,13 @@ internal object WeatherMixer : RNGConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
private fun initClouds() {
|
||||
repeat((currentWeather.cloudChance * 6.8f).ceilToInt()) { // multiplier is an empirical value that depends on the 'rZ'
|
||||
tryToSpawnCloud(currentWeather, ((Math.random() * 2.0 - 1.0) * App.scr.wf).toFloat())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun <T> Array<T?>.addAtFreeSpot(obj: T) {
|
||||
var c = 0
|
||||
while (true) {
|
||||
@@ -566,6 +579,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
cloudChance = JSON.getFloat("cloudChance"),
|
||||
cloudDriftSpeed = JSON.getFloat("cloudDriftSpeed"),
|
||||
cloudGamma = JSON["cloudGamma"].asFloatArray().let { Vector2(it[0], it[1]) },
|
||||
cloudGammaVariance = JSON["cloudGammaVariance"].asFloatArray().let { Vector2(it[0], it[1]) },
|
||||
clouds = cloudsMap,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class WeatherObjectCloud(private val texture: TextureRegion, private val flipW:
|
||||
val y = posY + offsetY - texture.regionHeight * scale
|
||||
val z = posZ // must be at least 1.0
|
||||
val w = App.scr.halfwf
|
||||
val h = App.scr.halfhf // 50% to the screen height, or 35%?
|
||||
val h = App.scr.hf * 0.35f
|
||||
|
||||
val drawX = (x + w * (z-1)) / z
|
||||
val drawY = (y + h * (z-1)) / z
|
||||
|
||||
Reference in New Issue
Block a user