something's not right with tile numbering

This commit is contained in:
minjaesong
2021-02-20 15:10:47 +09:00
parent 295dd8b8d6
commit 463e59087c
6 changed files with 21 additions and 10 deletions

BIN
assets/mods/basegame/blocks/0.tga LFS Normal file

Binary file not shown.

View File

@@ -1,6 +1,5 @@
"id";"drop";"name";"shdr";"shdg";"shdb";"shduv";"str";"dsty";"mate";"solid";"plat";"wall";"grav";"dlfn";"fv";"fr";"lumr";"lumg";"lumb";"lumuv";"colour";"vscs"
"0";"0";"BLOCK_AIR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"1";"N/A";"0";"0";"4";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
"1";"1";"BLOCK_MIASMA";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"1";"N/A";"0";"0";"4";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
"16";"17";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"0";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
"17";"17";"BLOCK_STONE_QUARRIED";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"0";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
"18";"18";"BLOCK_STONE_TILE_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"0";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
1 id drop name shdr shdg shdb shduv str dsty mate solid plat wall grav dlfn fv fr lumr lumg lumb lumuv colour vscs
2 0 0 BLOCK_AIR 0.0312 0.0312 0.0312 0.0312 1 1 NULL 0 0 1 N/A 0 0 4 0.0000 0.0000 0.0000 0.0000 N/A N/A
1 1 BLOCK_MIASMA 0.0312 0.0312 0.0312 0.0312 1 1 NULL 0 0 1 N/A 0 0 4 0.0000 0.0000 0.0000 0.0000 N/A N/A
3 16 17 BLOCK_STONE 0.1252 0.1252 0.1252 0.1252 48 2400 ROCK 1 0 1 N/A 0 4 16 0.0000 0.0000 0.0000 0.0000 N/A N/A
4 17 17 BLOCK_STONE_QUARRIED 0.1252 0.1252 0.1252 0.1252 48 2400 ROCK 1 0 1 N/A 0 4 16 0.0000 0.0000 0.0000 0.0000 N/A N/A
5 18 18 BLOCK_STONE_TILE_WHITE 0.1252 0.1252 0.1252 0.1252 48 2400 ROCK 1 0 1 N/A 0 4 16 0.0000 0.0000 0.0000 0.0000 N/A N/A

View File

@@ -137,7 +137,7 @@ object MinimapComposer : Disposable {
val tileTerr = world.getTileFromTerrain(x, y)
val wallTerr = world.getTileFromWall(x, y)
val colTerr = CreateTileAtlas.terrainTileColourMap.get(tileTerr)!!.toGdxColor()
val colWall = CreateTileAtlas.terrainTileColourMap.get(wallTerr)!!.toGdxColor().mul(BlocksDrawer.wallOverlayColour)
val colWall = CreateTileAtlas.terrainTileColourMap.get(wallTerr)!!.toGdxColor().mul(CreateTileAtlas.wallOverlayColour)
val outCol = if (colTerr.a > 0.1f) colTerr else colWall

View File

@@ -147,6 +147,8 @@ open class GameWorld : Disposable {
tileNumberToNameMap = HashMap<Int, ItemID>()
tileNameToNumberMap = HashMap<ItemID, Int>()
CreateTileAtlas.tags.forEach {
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
tileNumberToNameMap[it.value.tileNumber] = it.key
tileNameToNumberMap[it.key] = it.value.tileNumber
}
@@ -224,7 +226,14 @@ open class GameWorld : Disposable {
*/
fun getTileFromTerrain(rawX: Int, rawY: Int): ItemID {
val (x, y) = coerceXY(rawX, rawY)
return tileNumberToNameMap[layerTerrain.unsafeGetTile(x, y)]!!
try {
return tileNumberToNameMap[layerTerrain.unsafeGetTile(x, y)]!!
}
catch (e: NullPointerException) {
System.err.println("NPE for tilenum ${layerTerrain.unsafeGetTile(x, y)}")
throw e
}
}
/**

View File

@@ -55,9 +55,6 @@ internal object BlocksDrawer {
//val tileItemWall = Image(TILE_SIZE * 16, TILE_SIZE * GameWorld.TILES_SUPPORTED / 16) // 4 MB
val wallOverlayColour = Color(5f / 9f, 5f / 9f, 5f / 9f, 1f)
const val BREAKAGE_STEPS = 10
val WALL = GameWorld.WALL
@@ -582,7 +579,7 @@ internal object BlocksDrawer {
}
val vertexColour = when (mode) {
TERRAIN, WIRE, FLUID -> Color.WHITE
WALL -> wallOverlayColour
WALL -> CreateTileAtlas.wallOverlayColour
else -> throw IllegalArgumentException()
}

View File

@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.Fluid
@@ -35,6 +36,8 @@ object CreateTileAtlas {
private val TOTAL_TILES = TILES_IN_X * TILES_IN_X
val wallOverlayColour = Color(5f / 9f, 5f / 9f, 5f / 9f, 1f)
lateinit var atlas: Pixmap
lateinit var atlasAutumn: Pixmap
lateinit var atlasWinter: Pixmap
@@ -61,7 +64,6 @@ object CreateTileAtlas {
// 16 tiles are reserved for internal use: solid black, solid white, breakage stages.
// 0th tile is complete transparent tile and is also a BlockID of zero: air.
private var atlasCursor = 0
private var atlasCursorGlow = 0
private val atlasInit = "./assets/graphics/blocks/init.tga"
private var itemSheetCursor = 16
@@ -72,7 +74,6 @@ object CreateTileAtlas {
tags = HashMap<ItemID, RenderTag>()
itemSheetNumbers = HashMap<ItemID, Int>()
tags[Block.AIR] = RenderTag(0, RenderTag.CONNECT_SELF, RenderTag.MASK_NA)
atlas = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
atlasAutumn = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
@@ -160,7 +161,7 @@ object CreateTileAtlas {
// darken things for the wall
for (y in 0 until itemWallPixmap.height) {
for (x in 0 until itemWallPixmap.width) {
val c = Color(itemWallPixmap.getPixel(x, y)).mulAndAssign(BlocksDrawer.wallOverlayColour).toRGBA()
val c = Color(itemWallPixmap.getPixel(x, y)).mulAndAssign(wallOverlayColour).toRGBA()
itemWallPixmap.drawPixel(x, y, c)
}
}
@@ -281,6 +282,8 @@ object CreateTileAtlas {
}
tags[id] = RenderTag(atlasCursor, connectionType, maskType)
printdbg(this, "tileName ${id} ->> tileNumber ${atlasCursor}")
}
private fun drawToAtlantes(pixmap: Pixmap, glow: Pixmap, tilesCount: Int) {