new properties in apploader: aspectRatio

This commit is contained in:
minjaesong
2020-06-21 13:56:50 +09:00
parent 5b05a84684
commit 671882014e
7 changed files with 56 additions and 36 deletions

View File

@@ -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|
|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

View File

@@ -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");

View File

@@ -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
}

View File

@@ -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

View File

@@ -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<Double>, 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)
}

View File

@@ -312,6 +312,7 @@ internal object BiomeMaker : NoiseMaker {
0x229944ff.toInt(), // woodlands
0x77bb77ff.toInt(), // shrubland
0x88bb66ff.toInt(), // plains
0xeeddbbff.toInt(), // sands
0x888888ff.toInt() // rockyland
)
}

View File

@@ -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;
}