From 671882014ee7db3834fe473f4e0fb182ddafacf7 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 21 Jun 2020 13:56:50 +0900 Subject: [PATCH] new properties in apploader: aspectRatio --- REFERENCING.md | 6 +- src/net/torvald/terrarum/AppLoader.java | 3 + src/net/torvald/terrarum/Terrarum.kt | 2 +- .../modulebasegame/WorldgenLoadScreen.kt | 8 +-- .../modulebasegame/worldgenerator/Biomegen.kt | 55 ++++++++++++------- .../terrarum/tests/WorldgenNoiseSandbox.kt | 1 + work_files/energy_flow.gv | 17 +++--- 7 files changed, 56 insertions(+), 36 deletions(-) diff --git a/REFERENCING.md b/REFERENCING.md index 54f6b6992..f4aa76758 100644 --- a/REFERENCING.md +++ b/REFERENCING.md @@ -7,7 +7,7 @@ |0x10_0000..0x0FFF_FFFF|Items (dynamic\*) (267M possible)| |0x1000_0000..0x7FFF_FFFF|Actors (1879M possible)| |-1..-65536|Virtual Tiles| -|-2147483648..-1 (all negative numbers)|Faction (2147M possible)| +|-2147483648..-65537 (all negative numbers)|Faction (2147M possible)| * dynamic items have own properties that will persist through savegame. @@ -19,4 +19,6 @@ Actors range in-depth |0x2000_0000..0x4FFF_FFFF|Regular actors (e.g. almost all of them)| |0x5000_0000..0x5FFF_FFFF|Special (e.g. weapon swung, bullets, dropped item, particles)| |0x6000_0000..0x6FFF_FFFF|Rendered front (e.g. fake tile)| -|0x7000_0000..0x7FFF_FFFF|Rendered as screen overlay, not affected by light nor environment overlays| \ No newline at end of file +|0x7000_0000..0x7FFF_FFFF|Rendered as screen overlay, not affected by light nor environment overlays| + +Actor IDs are assigned in 256 groups, single actor can have 256 sub-actors \ No newline at end of file diff --git a/src/net/torvald/terrarum/AppLoader.java b/src/net/torvald/terrarum/AppLoader.java index e7c20ad38..3c7c6b0a6 100644 --- a/src/net/torvald/terrarum/AppLoader.java +++ b/src/net/torvald/terrarum/AppLoader.java @@ -243,6 +243,7 @@ public class AppLoader implements ApplicationListener { public static int halfScreenH = 0; public static float halfScreenWf = 0f; public static float halfScreenHf = 0f; + public static float aspectRatio = 0f; public static Texture textureWhiteSquare; public static Texture textureWhiteCircle; @@ -680,6 +681,8 @@ public class AppLoader implements ApplicationListener { halfScreenWf = (float) halfScreenW; halfScreenHf = (float) halfScreenH; + aspectRatio = screenWf / screenHf; + updateFullscreenQuad(screenW, screenH); printdbg(this, "Resize end"); diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 5e950f571..0f0fd6128 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -295,7 +295,7 @@ object Terrarum : Disposable { var ret: Int do { - ret = HQRNG().nextInt().and(0x7FFFFFFF) // set new ID + ret = HQRNG().nextInt().and(0x7FFFFF00) // set new ID } while (hasCollision(ret)) // check for collision return ret } diff --git a/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt b/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt index 6918da0c2..124150a7d 100644 --- a/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt +++ b/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt @@ -31,8 +31,8 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt private const val WIDTH_RATIO = 0.7 private const val PREVIEW_UPDATE_RATE = 1 / 5f - private val COL_WALL = Color.WHITE - private val COL_TERR = Color(.5f, .5f, .5f, 1f) + private val COL_TERR = Color.WHITE + private val COL_WALLED = Color(.5f, .5f, .5f, 1f) private val COL_AIR = Color.BLACK } @@ -94,9 +94,7 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt val wx = (world.width.toFloat() / previewWidth * x).roundToInt() val wy = (world.height.toFloat() / previewHeight * y).roundToInt() - val colT = if (world.getTileFromTerrain(wx, wy) != 0) COL_WALL else COL_TERR - val colW = if (world.getTileFromWall(wx, wy) != 0) COL_WALL else COL_AIR - val outCol = colW mul colT + val outCol = if (world.getTileFromTerrain(wx, wy) > 15) COL_TERR else if (world.getTileFromWall(wx, wy) > 15) COL_WALLED else COL_AIR previewPixmap.setColor(outCol) previewPixmap.drawPixel(x, previewHeight - 1 - y) // this flips Y diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Biomegen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Biomegen.kt index 67d6c963f..9a9ae1d28 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Biomegen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Biomegen.kt @@ -60,21 +60,30 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par AppLoader.printdbg(this, "Waking up Worldgen") } - val nearbyArr = arrayOf( - (-1 to -1), // tileTL - (+1 to -1), // tileTR - (-1 to +1), // tileBL - (+1 to +1), // tileBR - (0 to -1), // tileT - (0 to +1), // tileB - (-1 to 0), // tileL - (+1 to 0) // tileR - ) + companion object { + private const val slices = 5 + private val nearbyArr = arrayOf( + (-1 to -1), // tileTL + (+1 to -1), // tileTR + (-1 to +1), // tileBL + (+1 to +1), // tileBR + (0 to -1), // tileT + (0 to +1), // tileB + (-1 to 0), // tileL + (+1 to 0) // tileR + ) + private const val TL = 0 + private const val TR = 1 + private const val BL = 2 + private const val BR = 3 + private const val TP = 4 + private const val BT = 5 + private const val LF = 6 + private const val RH = 7 + } private fun draw(x: Int, y: Int, noiseValue: List, world: GameWorld) { - val control = noiseValue[0].times(4).minus(0.00001f).toInt().fmod(4) - - + val control = noiseValue[0].times(slices).minus(0.00001f).toInt().fmod(slices) if (y > 0) { val tileThis = world.getTileFromTerrain(x, y) @@ -84,22 +93,30 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par when (control) { 0 -> { // woodlands - if (world.getTileFromTerrain(x, y) == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) { + if (tileThis == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) { world.setTileTerrain(x, y, Block.GRASS) } } 1 -> { // shrublands - if (world.getTileFromTerrain(x, y) == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) { + if (tileThis == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) { world.setTileTerrain(x, y, Block.GRASS) } } - 2 -> { // plains - if (world.getTileFromTerrain(x, y) == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) { + 2, 3 -> { // plains + if (tileThis == Block.DIRT && nearbyTerr.any { it == Block.AIR } && nearbyWall.any { it == Block.AIR }) { world.setTileTerrain(x, y, Block.GRASS) } } - 3 -> { // rockylands - if (world.getTileFromTerrain(x, y) == Block.DIRT) { + /*3 -> { // sands + if (tileThis == Block.DIRT && (nearbyTerr[BT] == Block.STONE || nearbyTerr[BT] == Block.AIR)) { + world.setTileTerrain(x, y, Block.SANDSTONE) + } + else if (tileThis == Block.DIRT) { + world.setTileTerrain(x, y, Block.SAND) + } + }*/ + 4 -> { // rockylands + if (tileThis == Block.DIRT) { world.setTileTerrain(x, y, Block.STONE) world.setTileWall(x, y, Block.STONE) } diff --git a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt index 782b0dc82..e17fe39a6 100644 --- a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt +++ b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt @@ -312,6 +312,7 @@ internal object BiomeMaker : NoiseMaker { 0x229944ff.toInt(), // woodlands 0x77bb77ff.toInt(), // shrubland 0x88bb66ff.toInt(), // plains + 0xeeddbbff.toInt(), // sands 0x888888ff.toInt() // rockyland ) } diff --git a/work_files/energy_flow.gv b/work_files/energy_flow.gv index c98c75d00..d91e15858 100644 --- a/work_files/energy_flow.gv +++ b/work_files/energy_flow.gv @@ -1,4 +1,11 @@ digraph EnergyFlow { + labelfloat = true; + ranksep = 0.6; + nodesep = 0.4; + sep = 1.0; + overlap = voronoi; + splines = true; + newrank=true; subgraph power_source { // remove cluster_ to not visualize node [shape=box]; @@ -12,7 +19,7 @@ digraph EnergyFlow { Water; } - subgraph power { + subgraph cluster_power { node [style=filled]; label = Power; @@ -46,12 +53,4 @@ digraph EnergyFlow { Electric -> Battery [dir=both, weight = 16.0]; Kinetic -> "Compressed Air" [dir=both]; - - - labelfloat = true; - ranksep = 0.6; - nodesep = 0.4; - sep = 1.0; - overlap = voronoi; - splines = true; }