From b6a688c4841b12d425a94bfedcc983916411d885 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 24 Feb 2021 11:04:11 +0900 Subject: [PATCH] render is fixed (tile breakage not tested as loading items are still wip); air tile no longer has tilenum of 0 --- assets/graphics/blocks/init.tga | 4 ++-- assets/tiling.frag | 2 +- src/net/torvald/terrarum/gameworld/GameWorld.kt | 6 ++++++ .../torvald/terrarum/worlddrawer/CreateTileAtlas.kt | 11 ++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/assets/graphics/blocks/init.tga b/assets/graphics/blocks/init.tga index b1ecf0745..bbbfdde21 100644 --- a/assets/graphics/blocks/init.tga +++ b/assets/graphics/blocks/init.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:678f5a624e5f348863b195aa2b2e8a63f94608bee327d1021a441551ad1669b1 -size 16428 +oid sha256:4a920ad9d970b004d54293cbef244bff987513054f2bb272fa99635a4d9e7418 +size 16402 diff --git a/assets/tiling.frag b/assets/tiling.frag index b71bba952..b1a01fd64 100644 --- a/assets/tiling.frag +++ b/assets/tiling.frag @@ -76,7 +76,7 @@ void main() { int tile = getTileFromColor(tileFromMap); int breakage = getBreakageFromColor(tileFromMap); ivec2 tileXY = getTileXY(tile); - ivec2 breakageXY = getTileXY(breakage + 5); // +5 is hard-coded constant that depends on the atlas + ivec2 breakageXY = getTileXY(breakage + 5); // +5 is hard-coded constant that depends on the contents of the atlas // calculate the UV coord value for texture sampling // diff --git a/src/net/torvald/terrarum/gameworld/GameWorld.kt b/src/net/torvald/terrarum/gameworld/GameWorld.kt index 70182a238..fd366b0ec 100644 --- a/src/net/torvald/terrarum/gameworld/GameWorld.kt +++ b/src/net/torvald/terrarum/gameworld/GameWorld.kt @@ -152,6 +152,9 @@ open class GameWorld : Disposable { tileNumberToNameMap[it.value.tileNumber] = it.key tileNameToNumberMap[it.key] = it.value.tileNumber } + + // AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero + tileNumberToNameMap[0] = Block.AIR } /** @@ -201,6 +204,9 @@ open class GameWorld : Disposable { // TODO rename wire map } } + + // AN EXCEPTIONAL TERM: tilenum 0 is always redirected to Air tile, even if the tilenum for actual Air tile is not zero + tileNumberToNameMap[0] = Block.AIR } /** diff --git a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt index c4df1f179..d426a0054 100644 --- a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt +++ b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt @@ -60,7 +60,7 @@ 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 atlasCursor = 64 // 64 predefined tiles. The normal blocks (e.g. Air) should start from this number private val atlasInit = "./assets/graphics/blocks/init.tga" private var itemSheetCursor = 16 @@ -86,6 +86,14 @@ object CreateTileAtlas { atlasFluid.blending = Pixmap.Blending.None atlasGlow.blending = Pixmap.Blending.None + // populate the atlantes with atlasInit + // this just directly copies the image to the atlantes :p + val initPixmap = Pixmap(Gdx.files.internal(atlasInit)) + atlas.drawPixmap(initPixmap, 0, 0) + atlasAutumn.drawPixmap(initPixmap, 0, 0) + atlasWinter.drawPixmap(initPixmap, 0, 0) + atlasSpring.drawPixmap(initPixmap, 0, 0) + // get all the files applicable // first, get all the '/blocks' directory, and add all the files, regardless of their extension, to the list val tgaList = ArrayList>() //Pair of @@ -192,6 +200,7 @@ object CreateTileAtlas { itemWallTexture = Texture(itemWallPixmap) itemTerrainPixmap.dispose() itemWallPixmap.dispose() + initPixmap.dispose() initialised = true } }